|  | @@ -4,10 +4,10 @@ import cn.hnthyy.thmz.Utils.IDCardUtil;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.Utils.SeedUtil;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.Utils.StringUtil;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.comment.UserLoginToken;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.entity.his.APatientMi;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.entity.his.MzPatientMi;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.enums.YesNoEnum;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.service.his.APatientMiService;
 | 
	
		
			
				|  |  | -import cn.hnthyy.thmz.service.his.MzPatientMiService;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
	
		
			
				|  | @@ -53,4 +53,177 @@ public class APatientMiController {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//    /**
 | 
	
		
			
				|  |  | +//     * 保存住院病人信息
 | 
	
		
			
				|  |  | +//     *
 | 
	
		
			
				|  |  | +//     * @return
 | 
	
		
			
				|  |  | +//     */
 | 
	
		
			
				|  |  | +//    @UserLoginToken
 | 
	
		
			
				|  |  | +//    @RequestMapping(value = "/saveZyPatient", method = {RequestMethod.POST})
 | 
	
		
			
				|  |  | +//    public Map<String, Object> saveZyPatient(@RequestBody APatientMi aPatientMi) {
 | 
	
		
			
				|  |  | +//        Map<String, Object> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | +//        try {
 | 
	
		
			
				|  |  | +//            if (checkPatient(aPatientMi, resultMap)){
 | 
	
		
			
				|  |  | +//                return resultMap;
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            APatientMi aPatientMiDb=aPatientMiService.queryAPatientByMzNo(aPatientMi.getMzNo());
 | 
	
		
			
				|  |  | +//            if(aPatientMiDb==null){
 | 
	
		
			
				|  |  | +//                if(StringUtils.isBlank(aPatientMiDb.getInpatientNo())){
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//               //新增
 | 
	
		
			
				|  |  | +//                aPatientMiService
 | 
	
		
			
				|  |  | +//            }else {
 | 
	
		
			
				|  |  | +//                //修改
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            mzPatientMi.setIcCardNo(mzPatientMi.getIcCardNo().trim());
 | 
	
		
			
				|  |  | +//            MzPatientMi dbMzPatientMi=mzPatientMiService.queryByIcCardNo(mzPatientMi.getIcCardNo());
 | 
	
		
			
				|  |  | +//            if(dbMzPatientMi!=null){
 | 
	
		
			
				|  |  | +//                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +//                resultMap.put("message", "新增病人信息失败,已经存在相同的诊疗卡");
 | 
	
		
			
				|  |  | +//                return resultMap;
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            int num=mzPatientMiService.saveMzPatientMi(mzPatientMi);
 | 
	
		
			
				|  |  | +//            if(num==1){
 | 
	
		
			
				|  |  | +//                resultMap.put("code", 0);
 | 
	
		
			
				|  |  | +//                resultMap.put("message", "保存病人信息成功");
 | 
	
		
			
				|  |  | +//                resultMap.put("data",mzPatientMi);
 | 
	
		
			
				|  |  | +//                return resultMap;
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +//            resultMap.put("message", "保存病人信息失败");
 | 
	
		
			
				|  |  | +//            return resultMap;
 | 
	
		
			
				|  |  | +//        } catch (Exception e) {
 | 
	
		
			
				|  |  | +//            if (e instanceof DataIntegrityViolationException){
 | 
	
		
			
				|  |  | +//                if(e.getMessage().contains("将截断字符串或二进制数据")){
 | 
	
		
			
				|  |  | +//                    resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +//                    resultMap.put("message", "病人地址信息超长");
 | 
	
		
			
				|  |  | +//                    log.error("系统异常,错误信息{病人地址信息超长}");
 | 
	
		
			
				|  |  | +//                    return resultMap;
 | 
	
		
			
				|  |  | +//                }
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            e.printStackTrace();
 | 
	
		
			
				|  |  | +//            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +//            resultMap.put("message", StringUtils.isBlank(e.getMessage())?"系统出错,请联系管理员":e.getMessage());
 | 
	
		
			
				|  |  | +//            log.error("系统异常,错误信息{}", e.getMessage());
 | 
	
		
			
				|  |  | +//            return resultMap;
 | 
	
		
			
				|  |  | +//        }
 | 
	
		
			
				|  |  | +//    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 校验病人信息
 | 
	
		
			
				|  |  | +     * @param aPatientMi
 | 
	
		
			
				|  |  | +     * @param resultMap
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private boolean checkPatient(@RequestBody APatientMi aPatientMi, Map<String, Object> resultMap) {
 | 
	
		
			
				|  |  | +        if (aPatientMi == null) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人信息不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getName())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人姓名不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getSex())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人性别不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (aPatientMi.getBirthDate() == null) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人出生日期不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getMzNo())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人门诊编号不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getHomeTel())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人手机号码不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getMarryCode())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人婚姻状态不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getOccupationCode())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人职业不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getCountry())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人国籍不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getNationCode())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人民族不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getBirthPlace())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人出生地址不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getAccountStreet())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人户口地址不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getHomeStreet())) {
 | 
	
		
			
				|  |  | +            aPatientMi.setHomeStreet("-");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getEmployerStreet())) {
 | 
	
		
			
				|  |  | +            aPatientMi.setEmployerStreet("-");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(StringUtils.isNotBlank(aPatientMi.getSocialNo()) && !aPatientMi.getSocialNo().startsWith("K")){
 | 
	
		
			
				|  |  | +            //校验身份证号码格式
 | 
	
		
			
				|  |  | +            String checkResult = IDCardUtil.IdentityCardVerification(aPatientMi.getSocialNo());
 | 
	
		
			
				|  |  | +            if (StringUtils.isNotBlank(checkResult)) {
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", checkResult);
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //校验手机号码格式
 | 
	
		
			
				|  |  | +        String checkResult = StringUtil.isPhone(aPatientMi.getHomeTel());
 | 
	
		
			
				|  |  | +        if (StringUtils.isNotBlank(checkResult)) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", checkResult);
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //如果紧急联系人电话不为空,校验紧急联系电话号码
 | 
	
		
			
				|  |  | +        if(StringUtils.isNotBlank(aPatientMi.getRelationTel())){
 | 
	
		
			
				|  |  | +            checkResult = StringUtil.isPhone(aPatientMi.getRelationTel());
 | 
	
		
			
				|  |  | +            if(StringUtils.isNotBlank(checkResult)){
 | 
	
		
			
				|  |  | +                resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +                resultMap.put("message", checkResult);
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isBlank(aPatientMi.getSocialNo())) {
 | 
	
		
			
				|  |  | +            resultMap.put("code", -1);
 | 
	
		
			
				|  |  | +            resultMap.put("message", "病人身份证号码不能为空");
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return false;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |