Browse Source

Merge branch '2.0' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into 2.0

wangzhinan 11 months ago
parent
commit
953504efa1
20 changed files with 324 additions and 264 deletions
  1. 2 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeArticleDao.java
  2. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/article/KnowledgeCategoryDao.java
  3. 9 7
      business/base-service/src/main/java/com/yihu/jw/article/service/KnowledgeArticleDictService.java
  4. 5 0
      business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java
  5. 33 3
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  6. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java
  7. 15 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  8. 10 2
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  9. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/article/KnowledgeCategoryService.java
  10. 0 18
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeCategoryDao.java
  11. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleEndpoint.java
  12. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuNoLoginEndpoint.java
  13. 75 7
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java
  14. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  15. 26 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  16. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java
  17. 3 3
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java
  18. 56 91
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java
  19. 33 104
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthController.java
  20. 49 16
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthRecordController.java

+ 2 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeArticleDao.java

@ -1,10 +1,9 @@
package com.yihu.jw.hospital.dao.consult;
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
import java.util.List;

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/article/KnowledgeCategoryDao.java

@ -1,10 +1,10 @@
package com.yihu.jw.base.dao.article;
package com.yihu.jw.article.dao;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.JpaRepository;
/**
 * 健康文章分类

+ 9 - 7
business/base-service/src/main/java/com/yihu/jw/article/service/KnowledgeArticleDictService.java

@ -12,7 +12,7 @@ import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDeptDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
@ -69,6 +69,8 @@ public class KnowledgeArticleDictService extends BaseJpaService<KnowledgeArticle
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private KnowledgeCategoryDao knowledgeCategoryDao;
    @Autowired
    private UserDao userDao;
    @Autowired
@ -153,11 +155,11 @@ public class KnowledgeArticleDictService extends BaseJpaService<KnowledgeArticle
     */
    public KnowledgeArticleDictDO saveArticle(String jsonData, Integer type) throws Exception {
        KnowledgeArticleDictDO knowledgeArticleDO = EntityUtils.jsonToEntity(jsonData, KnowledgeArticleDictDO.class);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("articleNeedCheck").orElse(null);
        ;
//        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("articleNeedCheck").orElse(null);
        KnowledgeCategoryDO knowledgeCategoryDO = knowledgeCategoryDao.findById(knowledgeArticleDO.getCategorySecond()).orElse(null);
        Boolean articleNeedCheck = true;
        if (wlyyHospitalSysDictDO != null) {
            if (!wlyyHospitalSysDictDO.getDictValue().equalsIgnoreCase("1")) {
        if (knowledgeCategoryDO != null) {
            if (knowledgeCategoryDO.getIsCheck()==null||knowledgeCategoryDO.getIsCheck()!=1) {
                articleNeedCheck = false;
            }
        }
@ -180,13 +182,13 @@ public class KnowledgeArticleDictService extends BaseJpaService<KnowledgeArticle
            if (type == 1) {
                BaseDoctorDO userDO = doctorDao.findById(knowledgeArticleDO.getCreateUser()).orElse(null);
                ;
                if (userDO != null) {
                    knowledgeArticleDO.setCreateUserName(userDO.getName());
                }
            } else {
                BaseDoctorDO userDO = doctorDao.findById(knowledgeArticleDO.getCreateUser()).orElse(null);
                ;
                if (userDO != null) {
                    knowledgeArticleDO.setCreateUserName(userDO.getName());
                }

+ 5 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/family/service/WlyyFamilyMemberService.java

@ -293,6 +293,10 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
                        String age =
                        JSONObject object1 = dsyyPrescriptionService.buildAccountToHospital(familyName,familyName,idCard,)
                    }*/
                }else {
                    mixEnvelop.setStatus(407);
                    mixEnvelop.setMessage(object.getString("retMsg"));
                    return  mixEnvelop;
                }
            }
        }else if ("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
@ -1020,6 +1024,7 @@ public class WlyyFamilyMemberService extends BaseJpaService<WlyyPatientFamilyMem
            if (StringUtils.isNotBlank(patientId)){
                sql += " and t.patient = '"+patientId+"'";
            }
            sql += " order by t.create_time ";
            List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
            if (list!=null&&list.size()>0){
                for (Map<String,Object> map:list){

+ 33 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -364,6 +364,25 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    private HealthCareNewService healthCareNewService;
    //已就诊医生列表
    public PageEnvelop visitedDoctorPage(String patientId,String startTime,String endTime,Integer page,Integer size){
        String sql = "SELECT d.id,d.name,d.job_title_name jobTitleName,o.dept_name deptName,d.photo,date_format(MAX(o.create_time),'%Y-%m-%d %H:%i:%S' )" +
                " createTime,o.outpatient_type outpatientType ";
        String countSql = " select count(distinct d.id)";
        String filter = "" +
                "from wlyy_outpatient o,base_doctor d " +
                "WHERE o.patient='"+patientId+"' and o.doctor=d.id ";
        if(StringUtils.isNotBlank(startTime)){
            filter += " and o.create_time>='"+startTime+"' ";
        }
        if(StringUtils.isNotBlank(endTime)){
            filter += " and o.create_time<='"+endTime+" 23:59:59' ";
        }
        String orderBy = " GROUP BY d.id order by createTime desc limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    /**
     * 获取居民就诊记录接口
@ -7909,16 +7928,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    }
    public Map<String, Object> updatePatientInfo(String patient, String name, String idcard, String ssc, Integer sex, String townCode, String townName, String committeeCode, String committeeName, String address, String photo, String mobile, String province, String provinceName, String city, String cityName) {
    public Map<String, Object> updatePatientInfo(String patient, String name, String idcard,String cardType, String ssc, Integer sex, String townCode, String townName, String committeeCode, String committeeName, String address, String photo, String mobile, String province, String provinceName, String city, String cityName) {
        Map<String, Object> rs = new HashedMap();
        BasePatientDO basePatientDO = basePatientDao.findById(patient).orElse(null);
        PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01", patient, "1");
        if (StringUtils.isNoneBlank(name)) {
            basePatientDO.setName(name);
        }
        if (StringUtils.isNoneBlank(idcard)) {
            basePatientDO.setIdcard(idcard);
        if(StringUtils.isBlank(basePatientDO.getIdcard())){
            //身份证空才允许修改
            if (StringUtils.isNoneBlank(idcard)) {
                boolean tmp = basePatientDao.existsByIdcardAndDel(idcard,"1");
                if(tmp){
                    throw new ServiceException("该身份证已存在账号,不允许修改成此身份证");
                }
                basePatientDO.setIdcard(idcard);
            }
        }
        if (StringUtils.isNoneBlank(cardType)) {
            basePatientDO.setCardType(cardType);
        }
        if (sex != null) {
            basePatientDO.setSex(sex);
        }

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/survey/dao/SurveyUserAnswerDao.java

@ -22,7 +22,7 @@ public interface SurveyUserAnswerDao extends JpaRepository<WlyySurveyUserAnswerD
    @Query("From WlyySurveyUserAnswerDO c WHERE c.tempOptionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode,String surveyTempCode);
    @Query("SELECT DISTINCT c.patient from WlyySurveyUserAnswerDO c WHERE c.tempQuestionCode = ?1 and c.surveyTempCode = ?2")
    @Query("SELECT DISTINCT c from WlyySurveyUserAnswerDO c WHERE c.tempQuestionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findByTempQuestionCodeDistinctPatient(String tempQuestionCode,String surveyTempCode );

+ 15 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -175,6 +175,21 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        }//...
    }
    //判断手机号是否注册
    public Integer checkMobile(String mobile,String loginType){
        if ("2".equals(loginType)) {
            String sql = "select count(*) from base_doctor where mobile='"+mobile+"'";
            Integer count = this.getJdbcTemplate().queryForObject(sql,Integer.class);
            return count;
            //3.患者登录
        } else if ("3".equals(loginType)) {
            String sql = "select count(*) from base_patient where mobile='"+mobile+"'";
            Integer count = this.getJdbcTemplate().queryForObject(sql,Integer.class);
            return count;
        }
        return 0;
    }
    /**
     * 用户登录判读接口
     * 判断loginType查找用户信息

+ 10 - 2
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -347,7 +347,7 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        logger.info("login:登录进入2");
        String flag = parameters.get("flag");
        String loginType = parameters.get("login_type");
        String username = parameters.get("username");
        logger.info(username);
@ -398,6 +398,15 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            }
            String userPhone = wechatService.getUserPhoneByApplets(authCode);
            if (!StringUtils.isEmpty(userPhone)) {
                //判断手机号是否注册
                int count = userDetailsService.checkMobile(userPhone,loginType);
                if(count==0){
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
                    Oauth2Envelop oauth2Envelop = new Oauth2Envelop<>("用户不存在", -2, userPhone);
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
                parameters.put("username", userPhone);
            } else {
                HttpHeaders headers = new HttpHeaders();
@ -473,7 +482,6 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        wlyyUserSimple.setRefreshToken(token.getRefreshToken().getValue());
        wlyyUserSimple.setUser(parameters.get("username"));
        wlyyUserSimple.setState(parameters.get("state"));
        String loginType = parameters.get("login_type");
        String openid = parameters.get("openid");
        String wechatId = parameters.get("wechatId");
        logger.info("login:登录进入7");

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/article/KnowledgeCategoryService.java

@ -2,7 +2,7 @@ package com.yihu.jw.base.service.article;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.base.dao.article.KnowledgeCategoryDao;
import com.yihu.jw.article.dao.KnowledgeCategoryDao;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.mysql.query.BaseJpaService;

+ 0 - 18
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/dao/consult/KnowledgeCategoryDao.java

@ -1,18 +0,0 @@
package com.yihu.jw.hospital.dao.consult;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
/**
 * 健康文章分类
 * @author huangwenjie
 */
public interface KnowledgeCategoryDao extends JpaRepository<KnowledgeCategoryDO, String>, JpaSpecificationExecutor<KnowledgeCategoryDO> {
	@Query("update KnowledgeCategoryDO c set c.del = 0 where c.id = ?1")
	@Modifying
	void updateDel(String id);
}

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/ArticleEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.endpoint.article;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleDao;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -11,7 +12,6 @@ import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.service.consult.BasePatientBusinessService;
import com.yihu.jw.hospital.service.consult.KnowledgeArticleService;
import com.yihu.jw.hospital.service.consult.KnowledgeArticleUserService;

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/article/BaseMenuNoLoginEndpoint.java

@ -1,11 +1,11 @@
package com.yihu.jw.hospital.endpoint.article;
import com.yihu.jw.article.dao.KnowledgeArticleDao;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.service.BaseMenuManageService;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleBrowseDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDictDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;

+ 75 - 7
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/hospital/WlyyFamilyMemberController.java

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.endpoint.hospital;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BaseNatPatientFamilyMemberDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
@ -10,15 +11,21 @@ import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
import com.yihu.jw.hospital.family.service.PatientMemberDictService;
import com.yihu.jw.hospital.family.service.WlyyFamilyMemberService;
import com.yihu.jw.hospital.prescription.service.DsyyPrescriptionService;
import com.yihu.jw.hospital.prescription.service.entrance.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.sms.service.YkyyINSMSService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -75,7 +82,8 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
    private String wxId;
    @Autowired
    private DsyyPrescriptionService dsyyPrescriptionService;
    @Autowired
    private BasePatientDao patientDao;
    @ApiOperation("获取家人关系")
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.findRelationDict)
@ -389,6 +397,9 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
    //验证验证码
    public boolean verification(String client_id, String username, String code) {
        if (StringUtils.isEmpty(code)) {
            return false;
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("isNeedSMS").orElse(null);
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
            if (code.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
@ -397,8 +408,12 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
                return false;
            }
        }
        if (StringUtils.isEmpty(code)) {
            return false;
        //新增白名单判断-白名单验证码默认123456
        if("123456".equals(code)){
            WlyyHospitalSysDictDO dictDO = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("sms_captcha_white",username);
            if(dictDO!=null){
                return true;
            }
        }
        String key = client_id + ":" + username + KEY_SUFFIX;
        String _code = (String) redisTemplate.opsForValue().get(key);
@ -411,6 +426,32 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
        return false;
    }
    @PostMapping(value = "buildAccount")
    @ApiOperation(value = "账户建档接口")
    public ObjEnvelop buildAccount(@ApiParam(name = "userName", value = "姓名", required = false)
                                   @RequestParam(value = "userName",required = false)String userName,
                                   @ApiParam(name = "idNo", value = "身份证", required = false)
                                   @RequestParam(value = "idNo",required = false)String idNo,
                                   @ApiParam(name = "gend", value = "性别 1男 2女", required = false)
                                   @RequestParam(value = "gend",required = false)String gend,
                                   @ApiParam(name = "phone", value = "电话号码", required = false)
                                   @RequestParam(value = "phone",required = false)String phone,
                                   @ApiParam(name = "cardNo", value = "卡号", required = false)
                                   @RequestParam(value = "cardNo",required = false)String cardNo) throws Exception {
        try {
            BasePatientDO patientDO = patientDao.findById(getUID()).orElse(null);
            String operatorName = "";
            if(patientDO!=null){
                operatorName = patientDO.getName();
            }
            JSONObject obj = dsyyPrescriptionService.buildAccountToHospital(operatorName,userName,idNo,gend,phone,cardNo);
            return ObjEnvelop.getSuccess("ok",obj);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("创建失败");
        }
    }
    @ApiOperation("保存家人关系")
    @PostMapping(value = BaseHospitalRequestMapping.WlyyFamilyMember.saveFamilyRelation)
    public MixEnvelop saveFamilyRelation(@ApiParam(name = "jsonData", value = "jsonData", required = false)
@ -424,12 +465,18 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
            String medicareType = jsonObject.getString("medicareType");
            String medicare = jsonObject.getString("medicare");
            String clinicId = jsonObject.getString("clinicId");
            String buildAccount = jsonObject.getString("buildAccount");
            boolean checkCode =false;
            if(!StringUtils.isEmpty(code)){
                checkCode = this.verification(client_id, username, code);
            }else if(StringUtils.isEmpty(code)&&StringUtils.isEmpty(client_id)) {
            if(!"1".equals(buildAccount)){
                if(!StringUtils.isEmpty(code)){
                    checkCode = this.verification(client_id, username, code);
                }else if(StringUtils.isEmpty(code)&&StringUtils.isEmpty(client_id)) {
                    checkCode = true;
                }
            }else {
                checkCode = true;
            }
            if (checkCode) {
                String patientId = jsonObject.getString("patientId");
                String familyName = jsonObject.getString("familyName");
@ -449,6 +496,27 @@ public class WlyyFamilyMemberController extends EnvelopRestEndpoint {
                if (null != jsonObject.get("id")) {
                    id = jsonObject.get("id").toString();
                }
                if ("1".equals(buildAccount)&&"xm_dsyy_wx".equalsIgnoreCase(wxId)){
                    if (medicare==null||medicare==""){
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage("社保卡号为空无法建档!请核对社保卡号!");
                        return mixEnvelop;
                    }
                    //三院自费建档
                    BasePatientDO patientDO = patientDao.findById(getUID()).orElse(null);
                    String operatorName = "";
                    if(patientDO!=null){
                        operatorName = patientDO.getName();
                    }
                    JSONObject object = dsyyPrescriptionService.buildAccountToHospital(operatorName,familyName,idCard, IdCardUtil.getSexForIdcard_new(idCard),username,medicare);
                    if(!"00".equals(object.getString("retCode"))){
                        mixEnvelop.setStatus(408);
                        mixEnvelop.setMessage(object.getString("retMsg"));
                        return mixEnvelop;
                    }
                }
                //获取建档信息
                if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.hospital.endpoint.patient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
import com.yihu.jw.article.service.KnowledgeArticleDictService;
import com.yihu.jw.contant.CommonContant;
@ -36,7 +37,6 @@ import com.yihu.jw.es.service.StatisticsEsService;
import com.yihu.jw.es.service.yqfk.YqfkService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.healthUpload.service.BaseDoctorHealthUploadService;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;

+ 26 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -173,6 +173,26 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private MlwyyPrescriptionService mlwyyPrescriptionService;
    @GetMapping(value = "visitedDoctorPage")
    @ApiOperation(value = "已就诊医生列表")
    public PageEnvelop visitedDoctorPage(@ApiParam(name = "patientId", value = "居民id")
                                         @RequestParam(value = "patientId", required = true) String patientId,
                                         @ApiParam(name = "startTime", value = "开始时间")
                                         @RequestParam(value = "startTime", required = false) String startTime,
                                         @ApiParam(name = "endTime", value = "结束时间")
                                         @RequestParam(value = "endTime", required = false) String endTime,
                                         @ApiParam(name = "page", value = "第几页")
                                         @RequestParam(value = "page", required = true) Integer page,
                                         @ApiParam(name = "size", value = "分页大小")
                                         @RequestParam(value = "size", required = true) Integer size){
        try {
            return prescriptionService.visitedDoctorPage(patientId, startTime, endTime, page, size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = "updPrescriptionExpressage")
    @ApiOperation(value = "修改续方收货信息")
    public ObjEnvelop updPrescriptionExpressage(@ApiParam(name = "id", value = "收获信息id")
@ -1529,6 +1549,8 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                      @RequestParam(value = "ssc", required = true) String ssc,
                                      @ApiParam(name = "idcard", value = "居民身份证")
                                      @RequestParam(value = "idcard", required = true) String idcard,
                                      @ApiParam(name = "cardType", value = "证件类型")
                                      @RequestParam(value = "cardType", required = false) String cardType,
                                      @ApiParam(name = "sex", value = "性别")
                                      @RequestParam(value = "sex", required = false) Integer sex,
                                      @ApiParam(name = "town", value = "所在区code")
@ -1554,8 +1576,10 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                      @ApiParam(name = "cityName", value = "市名称")
                                      @RequestParam(value = "cityName", required = false) String cityName) {
        try {
            return success(prescriptionService.updatePatientInfo(patient, name, idcard, ssc, sex, town, townName, committeeCode, committeeName, address, photo, mobile, province, provinceName, city, cityName));
        } catch (Exception e) {
            return success(prescriptionService.updatePatientInfo(patient, name, idcard,cardType, ssc, sex, town, townName, committeeCode, committeeName, address, photo, mobile, province, provinceName, city, cityName));
        }catch (ServiceException se){
            return ObjEnvelop.getError(se.getMessage());
        }catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeArticleService.java

@ -1,6 +1,7 @@
package com.yihu.jw.hospital.service.consult;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.article.dao.KnowledgeArticleDao;
import com.yihu.jw.article.dao.KnowledgeArticleDeptDao;
import com.yihu.jw.article.dao.KnowledgeArticleDictDao;
import com.yihu.jw.article.dao.KnowledgeArticleUserDao;
@ -16,7 +17,6 @@ import com.yihu.jw.entity.hospital.article.KnowledgeArticleUserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyTemplateDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.survey.dao.SurveyTemplateDao;
import com.yihu.jw.hospital.survey.dao.SurveyUserDao;

+ 3 - 3
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/service/consult/KnowledgeCategoryService.java

@ -1,13 +1,13 @@
package com.yihu.jw.hospital.service.consult;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.article.dao.KnowledgeArticleDao;
import com.yihu.jw.article.dao.KnowledgeCategoryDao;
import com.yihu.jw.entity.hospital.article.KnowledgeArticleDO;
import com.yihu.jw.entity.hospital.article.KnowledgeCategoryDO;
import com.yihu.jw.hospital.dao.consult.KnowledgeArticleDao;
import com.yihu.jw.hospital.dao.consult.KnowledgeCategoryDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

+ 56 - 91
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientDeviceController.java

@ -15,7 +15,6 @@ import com.yihu.jw.hospital.module.health.service.PatientHealthIndexService;
import com.yihu.jw.hospital.module.wx.dao.WechatTemplateConfigDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.message.dao.MessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
@ -33,7 +32,10 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 患者端:设备管理控制类
@ -66,17 +68,20 @@ public class PatientDeviceController extends BaseController {
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDeviceLogService patientDeviceLogService;
    @Autowired
    private MessageDao messageDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    @ApiOperation("获取居民标准体征预警值")
    @RequestMapping(value = "getDeviceStandard", method = RequestMethod.GET)
    public String getDeviceStandard(@ApiParam(name = "type", value = "类型1血糖,2血压", defaultValue = "1")
    public String getDeviceStandard(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                        @RequestParam(value = "patientId", required = false) String patientId,
                                    @ApiParam(name = "type", value = "类型1血糖,2血压", defaultValue = "1")
                                    @RequestParam(value = "type", required = true) Integer type){
        try {
            JSONObject json = patientHealthIndexService.getealthStandard(type,getRepUID());
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONObject json = patientHealthIndexService.getealthStandard(type,patientId);
            return write(200,"获取成功","data",json);
        } catch (Exception ex) {
            error(ex);
@ -116,14 +121,18 @@ public class PatientDeviceController extends BaseController {
                               @RequestParam String deviceSN,
                               @RequestParam String categoryCode,
                               @RequestParam String userType,
                               @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                   @RequestParam(value = "patientId", required = false) String patientId,
                               @RequestParam(required = false) String newDeviceSN,
                               @RequestParam(required = false) String hospital,
                               @RequestParam(required = false) String hospitalName,
                               @RequestParam(required = false) String checkDoctorName) {
        try {
//            String user = getUID();
            String user = getRepUID();
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            String user = patientId;
            if (StringUtils.isNotEmpty(newDeviceSN)) {
//                校验新的sn码 1.是否被占用 2.是否是真的设备码
@ -133,10 +142,6 @@ public class PatientDeviceController extends BaseController {
                    if (device != null) {
                        throw new Exception("sn码" + newDeviceSN + "已被使用!");
                    }
//                    if(!patientDeviceService.checkDeviceSn(newDeviceSN)){
//                        return error(-1,"设备不存在");
//                    }
                }
                if ("1".equals(categoryCode)) {
//                        先修改患者设备绑定表
@ -174,19 +179,22 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"06B52305030267\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                             @RequestParam(value = "patientId", required = false) String patientId,
                             @ApiParam(name="isScan",value="是否扫一扫 1是0否,默认否",required = false)
                             @RequestParam(value="isScan",required = false) String isScan) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            if(StringUtils.isBlank(device.getDeviceSn())){
                return write(-1,"sn码不能为空!");
            }
            // 设置患者标识
            if(StringUtils.isBlank(device.getUser())){
                device.setUser(getRepUID());
                device.setUser(patientId);
            }
//            device.setUser(getUID());
            //患者和设备是否首绑
            Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
            boolean flag = (Boolean)checkMap.get("flag");
@ -195,11 +203,11 @@ public class PatientDeviceController extends BaseController {
                return write(-1,"设备不存在或者数据存在错误!");
            }
            BasePatientDO patient = patientService.findById(getRepUID()).orElse(null);
            if(!getUID().equals(getRepUID())&&device.getId()==null){
                device.setAgent(getRepUID());
                device.setAgentName(patient.getName());
            }
            BasePatientDO patient = patientService.findById(patientId).orElse(null);
//            if(!getUID().equals(patientId)&&device.getId()==null){
//                device.setAgent(patientId);
//                device.setAgentName(patient.getName());
//            }
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                patientDeviceService.saveDevice(device,isScan);
@ -252,10 +260,15 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "PatientDeviceList", method = RequestMethod.GET)
    public String getDeviceByPatient(@ApiParam(name = "id", value = "分页起始id", defaultValue = "0")
                                     @RequestParam(value = "id", required = true) long id,
                                     @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                     @RequestParam(value = "patientId", required = false) String patientId,
                                     @ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
                                     @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            Page<DevicePatientDevice> list = patientDeviceService.findByPatient(getRepUID(), id, pagesize);
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            Page<DevicePatientDevice> list = patientDeviceService.findByPatient(patientId, id, pagesize);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
@ -293,13 +306,15 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "PatientDeviceIdcard", method = RequestMethod.GET)
    public String getDeviceUser(@ApiParam(name = "type", value = "设备类型", defaultValue = "1")
                                @RequestParam(value = "type", required = true) String type,
                                @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                @RequestParam(value = "patientId", required = false) String patientId,
                                @ApiParam(name = "device_sn", value = "设备SN码", defaultValue = "15L000002")
                                @RequestParam(value = "device_sn", required = true) String deviceSn) {
        try {
//            if (!"11".equals(type)&&deviceDetailService.findByDeviceSn(deviceSn)==null){
//                return write(-1,"设备不存在!");
//            }
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(getRepUID(), deviceSn, type);
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            List<Map<String, String>> list = patientDeviceService.getDeviceUser(patientId, deviceSn, type);
            return write(200, "获取设备绑定信息成功!", "data", list);
        } catch (Exception ex) {
            error(ex);
@ -314,50 +329,27 @@ public class PatientDeviceController extends BaseController {
    @RequestMapping(value = "sendDeviceReviewMessage",method = RequestMethod.POST)
    public String sendDeviceReviewMessage(@ApiParam(name = "id", value = "删除设备关联ID")
                                              @RequestParam(value = "id", required = true) String id,
                                          @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                          @RequestParam(value = "patientId", required = false) String patientId,
                                          @ApiParam(name = "reson", value = "解绑理由")
                                          @RequestParam(value = "reson", required = true) String reson){
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            DevicePatientDevice pd = patientDeviceService.findById(id);
            if (pd != null) {
//                if (!StringUtils.equals(pd.getUser(), getUID())) {
                if (!StringUtils.equals(pd.getUser(), getRepUID())) {
                if (!StringUtils.equals(pd.getUser(), patientId)) {
                    return error(-1, "只允许删除自己的设备!");
                }
                //居民自主解绑设备时发送消息给医生
                BasePatientDO patient = patientService.findById(getRepUID()).orElse(null);
                BasePatientDO patient = patientService.findById(patientId).orElse(null);
                String messageContent =  "您的居民"+patient.getName()+"申请解绑智能设备:"+pd.getDeviceName()+",请及时处理";
//                if ("1".equals(pd.getCategoryCode())){
//                    messageContent +="血糖仪,点击下方查看居民详情";
//                }else if ("2".equals(pd.getCategoryCode())){
//                    messageContent +="血压计,点击下方查看居民详情";
//                }else if ("4".equals(pd.getCategoryCode())){
//                    messageContent +="智能手表,点击下方查看居民详情";
//                }
                
                JSONObject contentObj = new JSONObject();
                contentObj.put("reason",reson);
                contentObj.put("messageContent",messageContent);
                contentObj.put("patientName",patient.getName());
                
/*                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent(contentObj.toString());
                message.setRead(1);//设置未读
                message.setReceiver(signFamily.getDoctor());//设置接受医生的code
                message.setSender("admin");//设置发送的用户
                message.setSenderName("系统");
                message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
                message.setSenderPhoto("");
                message.setTitle("解绑设备审核消息");
                message.setType(302);//解绑设备消息
                message.setReadonly(1);//是否只读消息
                message.setSex(1);
                message.setRelationCode(id);
                message.setOver("1");//未处理
                message.setData("");
                message.setDel("1");
                messageDao.save(message);*/
    
                pd.setApplyStatus(1);//审核中
                pd.setApplyReason(reson);
@ -379,47 +371,20 @@ public class PatientDeviceController extends BaseController {
    @ApiOperation("设备删除")
    @RequestMapping(value = "DeletePatientDevice",method = {RequestMethod.GET,RequestMethod.POST})
    public String delete(@ApiParam(name = "id", value = "删除设备关联ID")
                         @RequestParam(value = "id", required = true) String id) {
                         @RequestParam(value = "id", required = true) String id,
                         @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                         @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            DevicePatientDevice pd = patientDeviceService.findById(id);
            if (pd != null) {
//                if (!StringUtils.equals(pd.getUser(), getUID())) {
                if (!StringUtils.equals(pd.getUser(), getRepUID())) {
                if (!StringUtils.equals(pd.getUser(), patientId)) {
                    return error(-1, "只允许删除自己的设备!");
                }
                // 删除设备
                patientDeviceService.deleteDevice(id, getRepUID());
//                patientDeviceService.deleteDevice(id, getUID());
                //居民自主解绑设备时发送消息给医生
                BasePatientDO patient = patientService.findById(getRepUID()).orElse(null);
                String messageContent =  "您的居民"+patient.getName()+"解绑了";
                if ("1".equals(pd.getCategoryCode())){
                    messageContent +="血糖仪,点击下方查看居民详情";
                }else if ("2".equals(pd.getCategoryCode())){
                    messageContent +="血压计,点击下方查看居民详情";
                }else if ("4".equals(pd.getCategoryCode())){
                    messageContent +="智能手表,点击下方查看居民详情";
                }
/*                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent(messageContent);
                message.setRead(1);//设置未读
                message.setReceiver(signFamily.getDoctor());//设置接受医生的code
                message.setSender("admin");//设置发送的用户
                message.setSenderName("系统");
                message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
                message.setSenderPhoto("");
                message.setTitle("解绑设备消息");
                message.setType(301);//解绑设备消息
                message.setReadonly(1);//是否只读消息
                message.setSex(1);
                message.setRelationCode(patient.getCode());
                message.setOver("1");//未处理
                message.setData("");
                message.setDel("1");
                messageDao.save(message);*/
                patientDeviceService.deleteDevice(id, patientId);
                //全部解绑后去判断就更新设备表中是否绑定字段
                patientDeviceLogService.savePatientDeviceLog(pd,pd.getDeviceSn(),2,2);
                deviceDetailService.unBindUpdateIsBinding(pd.getDeviceSn());

+ 33 - 104
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthController.java

@ -13,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@ -25,9 +24,6 @@ public class PatientHealthController extends BaseController {
    @Autowired
    private PatientHealthIndexService healthIndexService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 更改接口(包括手动记录的修改和所有的删除)
@ -61,11 +57,14 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "/getRecentData", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("患者最近的各项健康信息")
    public String getRecentData() {
    public String getRecentData(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                    @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            List list = new ArrayList();
            String patient = getRepUID();
//            String patient = getUID();
            String patient = patientId;
//            健康指标类型(1血糖,2血压,3体重,4腰围)
            Map map = healthIndexService.findDataByPatient(patient, 1);
            Map map1 = healthIndexService.findDataByPatient(patient, 2);
@ -241,9 +240,13 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "recent", method = RequestMethod.GET)
    @ApiOperation("患者最近填写的健康指标")
    public String recent() {
    public String recent(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                             @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            JSONArray array = healthIndexService.findRecentByPatient(getRepUID());
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONArray array = healthIndexService.findRecentByPatient(patientId);
            if (array != null) {
                return write(200, "查询成功", "list", array);
            } else {
@ -259,10 +262,14 @@ public class PatientHealthController extends BaseController {
    @RequestMapping(value = "last", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取患者最后填写的健康指标(新)")
    public String last() {
    public String last(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                           @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            Map<String, Object> map = new HashMap<>();
            String patient = getRepUID();
            String patient = patientId;
            DevicePatientHealthIndex xt = healthIndexService.findLastByPatienIot(patient, 1);
            if (xt != null) {
                map.put("xt", xt);
@ -293,40 +300,6 @@ public class PatientHealthController extends BaseController {
        }
    }
    @RequestMapping(value = "last_new", method = RequestMethod.GET)
    @ApiOperation("获取患者最后填写的健康指标(新)-展会")
    public String last_new() {
        try {
            Map<String, Object> map = new HashMap<>();
            String patient = getRepUID();
            DevicePatientHealthIndex xt = healthIndexService.findLastByPatienIot(patient, 1);
            if (xt != null) {
                map.put("xt", xt);
            }
            DevicePatientHealthIndex xy = healthIndexService.findLastByPatienIot(patient, 2);
            if (xy != null) {
                map.put("xy", xy);
            }
            DevicePatientHealthIndex tz = healthIndexService.findLastByPatienIot(patient, 3);
            if (tz != null) {
                map.put("tz", tz);
            }
            DevicePatientHealthIndex sg = healthIndexService.findLastByPatienIot(patient, 4);
            if (sg != null) {
                map.put("sg", sg);
            }
            DevicePatientHealthIndex xl = healthIndexService.findLastByPatienIot(patient, 5);
            if (xl != null) {
                map.put("xl", xl);
            }
            return write(200, "查询成功", "data", map);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @RequestMapping(value = "addPatientHealthIndex", method = RequestMethod.POST)
    @ApiOperation("新增患者指标")
    public String addPatientHealthIndex(@ApiParam(name = "data", value = "指标数据", defaultValue = "{\"gi\":\"5.5\",\"gi_type\":\"1\"}")
@ -345,10 +318,6 @@ public class PatientHealthController extends BaseController {
            if (type.equals("1") || type.equals("2")) {
                healthIndexService.verifyHealthIndex(obj.getId());
            }
            //判断居民的体征预警状态
//            healthIndexService.handlePatientStandarStatus(obj);
            return success("新增患者指标成功!");
        } catch (ServiceException se) {
            return write(-1,se.getMessage());
@ -378,36 +347,17 @@ public class PatientHealthController extends BaseController {
                                               @RequestParam(value = "type", required = true) int type,
                                               @ApiParam(name = "gi_type", value = "就餐类型0全部", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) int gi_type,
                                               @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                                   @RequestParam(value = "patientId", required = false) String patientId,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            JSONArray jsonArray = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    @RequestMapping(value = "chart_new", method = RequestMethod.POST)
    @ApiOperation("根据患者标志获取健康指标(图表)-展会")
    public String getHealthIndexChartByPatient_new(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重,4腰围)", defaultValue = "1")
                                               @RequestParam(value = "type", required = true) int type,
                                               @ApiParam(name = "gi_type", value = "就餐类型0全部", defaultValue = "1")
                                               @RequestParam(value = "gi_type", required = false) int gi_type,
                                               @ApiParam(name = "begin", value = "开始时间", defaultValue = "2017-05-22 00:00:00")
                                               @RequestParam(value = "begin", required = true) String begin,
                                               @ApiParam(name = "end", value = "结束时间", defaultValue = "2017-06-02 00:00:00")
                                               @RequestParam(value = "end", required = true) String end) {
        try {
            JSONArray jsonArray = healthIndexService.findChartByPatient(getRepUID(), type, gi_type, begin, end);
            if (jsonArray.length()==0) {
                return success("查询成功!");
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONArray jsonArray = healthIndexService.findChartByPatient(patientId, type, gi_type, begin, end);
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
@ -424,6 +374,8 @@ public class PatientHealthController extends BaseController {
                                          @RequestParam(value = "start", required = true) String start,
                                          @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-08-23 00:00:00")
                                          @RequestParam(value = "end", required = true) String end,
                                          @ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                                              @RequestParam(value = "patientId", required = false) String patientId,
                                          @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                          @RequestParam(value = "page", required = true) int page,
                                          @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
@ -432,10 +384,10 @@ public class PatientHealthController extends BaseController {
            JSONObject jsonObject2 = new JSONObject();
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getRepUID(), type, start, end, page, pagesize);
                List<Object> list = healthIndexService.findIndexByPatient2(patientId, type, start, end, page, pagesize);
                jsonObject2.put("data",list);
            } else {
                jsonArray = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
                jsonArray = healthIndexService.findIndexByPatient(patientId, type, start, end, page, pagesize);
                JSONArray jsonArray1 = new JSONArray();
                jsonObject2.put("data",jsonArray);
            }
@ -446,41 +398,18 @@ public class PatientHealthController extends BaseController {
        }
    }
    @RequestMapping(value = "list_new", method = RequestMethod.POST)
    @ApiOperation("患者获取健康指标-展会")
    public String getHealthIndexByPatient_new(@ApiParam(name = "type", value = "指标类型(1血糖,2血压,3体重/身高,4腰围)", defaultValue = "1")
                                          @RequestParam(value = "type", required = true) int type,
                                          @ApiParam(name = "start", value = "开始时间", defaultValue = "2016-07-23 00:00:00")
                                          @RequestParam(value = "start", required = true) String start,
                                          @ApiParam(name = "end", value = "结束时间", defaultValue = "2016-08-23 00:00:00")
                                          @RequestParam(value = "end", required = true) String end,
                                          @ApiParam(name = "page", value = "第几页", defaultValue = "1")
                                          @RequestParam(value = "page", required = true) int page,
                                          @ApiParam(name = "pagesize", value = "每页几行", defaultValue = "10")
                                          @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            JSONArray jsonArray = new JSONArray();
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getRepUID(), type, start, end, page, pagesize);
                jsonArray = new JSONArray(list);
            } else {
                jsonArray = healthIndexService.findIndexByPatient(getRepUID(), type, start, end, page, pagesize);
            }
            return write(200, "查询成功", "list", jsonArray);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, "查询失败!");
        }
    }
    @RequestMapping(value = "standard", method = RequestMethod.GET)
    @ApiOperation("患者健康指标预警值查询")
    public String standard() {
    public String standard(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
                               @RequestParam(value = "patientId", required = false) String patientId) {
        try {
            if(StringUtils.isBlank(patientId)){
                patientId = getRepUID();
            }
            JSONArray standardArray = new JSONArray();
            JSONArray userArray = new JSONArray();
            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(getRepUID());
            Iterable<PatientHealthStandard> iterable = healthIndexService.findStandardByPatient(patientId);
            Iterator<PatientHealthStandard> iterator = null;
            if (iterable != null) {
                iterator = iterable.iterator();

+ 49 - 16
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/health/controller/PatientHealthRecordController.java

@ -10,6 +10,7 @@ import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -165,13 +166,17 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "add_sports", method ={ RequestMethod.POST})
	@ApiOperation("添加运动记录")
	public String addSports(String record_date, double sportsTime, String sportsType, String sports) {
	public String addSports(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
								@RequestParam(value = "patientId", required = false) String patientId,
							String record_date, double sportsTime, String sportsType, String sports) {
		try {
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			PatientHealthRecordSports record = new PatientHealthRecordSports();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setPatient(patientId);
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setSportsTime(sportsTime);
@ -195,13 +200,17 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "add_medication", method ={ RequestMethod.POST})
	@ApiOperation("添加用药记录")
	public String addMedication(String record_date, String medicines, String medicines_name) {
	public String addMedication(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
									@RequestParam(value = "patientId", required = false) String patientId,
								String record_date, String medicines, String medicines_name) {
		try {
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			PatientHealthRecordMedication record = new PatientHealthRecordMedication();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
//			record.setPatient(getUID());
			record.setPatient(patientId);
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setMedicines(medicines);
@ -226,12 +235,17 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "add_diet", method ={ RequestMethod.POST})
	@ApiOperation("添加饮食记录接口")
	public String add(String record_date, String content, @RequestParam(required = false) String images) {
	public String add(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
						  @RequestParam(value = "patientId", required = false) String patientId,
					  String record_date, String content, @RequestParam(required = false) String images) {
		try {
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			PatientHealthRecordDiet record = new PatientHealthRecordDiet();
			record.setDel("1");
			record.setCzrq(new Date());
			record.setPatient(getRepUID());
			record.setPatient(patientId);
			record.setRecordDate(DateUtil.strToDateShort(record_date));
			record.setSortDate(DateUtil.strToDateAppendNowTime(record_date, DateUtil.YYYY_MM_DD_HH_MM_SS));
			record.setContent(content);
@ -253,9 +267,13 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "recent", method ={ RequestMethod.GET})
	@ApiOperation("最近填写的运动、用药、饮食内容")
	public String recent() {
	public String recent(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
							 @RequestParam(value = "patientId", required = false) String patientId) {
		try {
			JSONObject json = patientHealthRecordService.findRecentByPatient(getRepUID());
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			JSONObject json = patientHealthRecordService.findRecentByPatient(patientId);
			if (json != null) {
				return write(200, "查询成功", "data", json);
			} else {
@ -274,9 +292,14 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_sports", method ={RequestMethod.GET})
	@ApiOperation("运动记录查询接口")
	public String sports(String start,String end,int page, int pagesize) {
	public String sports(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
							 @RequestParam(value = "patientId", required = false) String patientId,
						 String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(getRepUID(), start,end,page, pagesize);
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			Page<PatientHealthRecordSports> data = patientHealthRecordService.findSportsByPatientPage(patientId, start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordSports record : data) {
@ -315,9 +338,14 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_medication", method ={RequestMethod.GET})
	@ApiOperation("用药记录查询接口")
	public String medication(String start,String end,int page, int pagesize) {
	public String medication(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
								 @RequestParam(value = "patientId", required = false) String patientId,
							 String start,String end,int page, int pagesize) {
		try {
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(getRepUID(), start, end, page, pagesize);
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			Page<PatientHealthRecordMedication> data = patientHealthRecordService.findMedicalByPatientPage(patientId, start, end, page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordMedication record : data) {
@ -352,9 +380,14 @@ public class PatientHealthRecordController extends BaseController {
	 */
	@RequestMapping(value = "list_diet", method ={ RequestMethod.GET})
	@ApiOperation("饮食记录查询接口")
	public String diet(String start,String end,int page,int pagesize) {
	public String diet(@ApiParam(name = "patientId", value = "居民id", defaultValue = "0")
						   @RequestParam(value = "patientId", required = false) String patientId,
					   String start,String end,int page,int pagesize) {
		try {
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(getRepUID(),start,end,page, pagesize);
			if(StringUtils.isBlank(patientId)){
				patientId = getRepUID();
			}
			Page<PatientHealthRecordDiet> data = patientHealthRecordService.findDietByPatientPage(patientId,start,end,page, pagesize);
			if (data != null) {
				JSONArray array = new JSONArray();
				for (PatientHealthRecordDiet record : data) {