瀏覽代碼

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

yeshijie 7 年之前
父節點
當前提交
1b0c07a367

+ 2 - 2
common/common-entity/src/main/java/com/yihu/device/entity/DevicePatientHealthIndex.java

@ -25,9 +25,9 @@ public class DevicePatientHealthIndex extends IdEntity {
	private String value1;
	// 舒张压/早餐后空腹/身高
	private String value2;
	// 午餐空腹/身高
	// 午餐空腹/BMI
	private String value3;
	// 午餐后
	// 午餐后/偏胖-1/正常0/偏瘦1
	private String value4;
	// 晚餐空腹
	private String value5;

+ 6 - 6
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java

@ -13,12 +13,12 @@ import java.sql.Timestamp;
@Entity
@Table(name = "wlyy_patient_aim_sports")
public class PatientAimSports extends IdEntity {
    private String code;
    private String patientcode;
    private Integer dailyStepCount;
    private String bmiMax;
    private String bmiMin;
    private Timestamp createTime;
    private String code;                //业务逻辑CODE,如果CODE为default,则该条记录为系统预置数据
    private String patientcode;         //患者CODE
    private Integer dailyStepCount;     //运动步数
    private String bmiMax;              //bmi标准上限
    private String bmiMin;              //bmi标准下线
    private Timestamp createTime;       //创建时间
    @Basic

+ 9 - 9
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java

@ -46,9 +46,9 @@ public class HealthArtListener implements MessageListener {
    public void onMessage(Message message) {
        try {
            TextMessage textMessage = (TextMessage) message;
            JSONObject jo = JSONObject.fromObject(textMessage.getText());
            logger.info(jo.toString());
            HealthEduArticlePatient healthEduArticlePatient = (HealthEduArticlePatient)JSONObject.toBean(JSONObject.fromObject(textMessage.getText()),HealthEduArticlePatient.class);
//            logger.info(jo.toString());
            sendWxTemplateAndIM(healthEduArticlePatient);
            //返回服务器表示消息消费成功
            message.acknowledge();
        } catch (JMSException e) {
@ -57,15 +57,15 @@ public class HealthArtListener implements MessageListener {
    }
    //发送到IM和
    private void sendWxTemplateAndIM(List<HealthEduArticlePatient> healthEduArticlePatients, Integer sendType) {
    //发送到IM和微信消息模板
    private void sendWxTemplateAndIM(HealthEduArticlePatient one) {
        String endMsg = "";//"为了您的健康," + doctor.getName() + "医生给您发送了一篇患教文章,请仔细查阅,如有问题,可随时咨询医生。";
        healthEduArticlePatients.stream().forEach(one -> {
//        healthEduArticlePatients.stream().forEach(one -> {
            Patient patient = patientService.findByCode(one.getPatient());
            try {
                //卫纪委发送不推IM
                if (1 == sendType) {
                if (1 == one.getSendType()) {
                    consultService.sendMucMessageBySingnType(one.getSendCode(), one.getSendName(), patient.getCode(), "{\"title\":\"" + one.getAttachedTitle() + "\",\"type\":0,\"id\":\"" + one.getId() + "\",\"img\":\"" + one.getAttachedPic() + "\",\"content\":\"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通\"}", "4", patient.getName());
                    if (StringUtils.isNotBlank(one.getAttachedMessage())) {
                        //发送备注
@ -76,7 +76,7 @@ public class HealthArtListener implements MessageListener {
                org.json.JSONObject json = new org.json.JSONObject();
                json.put("first", patient.getName() + ",您好! " + one.getSendName() + "医生给您发来了一篇患教文章");
                json.put("toUser", patient.getCode());
                json.put("article", one.getId() + "");
                json.put("article", one.getArticleId() + "");
                json.put("title", one.getAttachedTitle());
                json.put("doctorName", one.getSendName());
                json.put("represented", patient.getCode());//被代理人
@ -111,6 +111,6 @@ public class HealthArtListener implements MessageListener {
            } catch (Exception e) {
                logger.error("patient:" + patient.getCode() + "," + e.getMessage());
            }
        });
//        });
    }
}

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientAimSportsDao.java

@ -0,0 +1,23 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 居民-运动目标
 * @author huangwenjie
 * @date 2017/9/12 16:07
 */
public interface PatientAimSportsDao extends
        PagingAndSortingRepository<PatientAimSports, Long>,
        JpaSpecificationExecutor<PatientAimSports> {
    @Query("from PatientAimSports p where p.code=?1")
    PatientAimSports findByCode(String code);
    @Query("from PatientAimSports p where p.patientcode =?1")
    PatientAimSports getPatientAimSportsByPatientCode(String patientCode);
}

+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -2,7 +2,6 @@ package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

+ 56 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -31,10 +31,13 @@ import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -87,7 +90,10 @@ public class PatientInfoService extends BaseService {
    PatientService patientService;
    @Autowired
    SystemDictDao systemDictDao;
    @Autowired
    JwArchivesService jwArchivesService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    /**
     * 患者更换手机号
@ -328,4 +334,53 @@ public class PatientInfoService extends BaseService {
        return 1;
    }
    public int createProfile(String doctorCode ,String patient,String jwCountryCode,String nation,String blood,String marry)throws Exception{
        Patient p = patientDao.findByCode(patient);
        JSONObject json = new JSONObject();
        json.put("ARCHIVE_TIME", DateUtil.getStringDateShort());//建档时间
        json.put("ARCHIVE_STATUS","3");//档案状态【1.未管理 2.死亡 3.正常 4.高危】
        json.put("SICK_NAME",p.getName());//姓名
        json.put("SICK_SEX",p.getSex());//性别【1.男 2.女 9 未知】
        json.put("BIRTHDAY",p.getBirthday());//出生日期
        json.put("ZONE_CODE",jwCountryCode);//所属社区【ZONE_DICT】
        json.put("IDENTITY_TYPE","1");//证件类型【IDENTITY_TYPE_DICT】
        json.put("IDENTITY_CARD_NO",p.getIdcard());//身份证号
        json.put("HOME_PHONE",p.getMobile());//本人电话
        json.put("HOME_ADDRESS","测试地址");//现住址
        json.put("ORG_ID","0");//新增默认传0
        json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
        json.put("NATIONAL",nation);//民族【NATION_DICT】
        json.put("ORIGO","3502030502");//户口所在地【ZONE_DICT】
        json.put("BLOOD",blood);//血型【1.A型 2.3.O型4.AB型 5.不详】
        json.put("BLOOD_RH","1");//RH阴性【1.否 2.是 3.不详】
        json.put("MARRIAGE",marry);//婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
        String doctor = doctorCode;
        String response = jwArchivesService.saveSickArchiveRecord(json.toString(),doctor);
        return 1;
    }
    public  List<Map<String,Object>> getNationDict(){
        String sql = "SELECT t.NATION_CODE,t.NATION_NAME FROM zy_nation_dict t ";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public List<Map<String,Object>> getMarryDict(){
        return getDictByName("MARRY_STATE");
    }
    public List<Map<String,Object>> getBloodDict(){
        return getDictByName("BLOOD_TYPE");
    }
    public List<Map<String,Object>> getDictByName(String name){
        String sql = "SELECT t.code,t.`value` FROM system_dict t WHERE t.dict_name=?";
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql,new Object[]{name});
        return rs;
    }
}

+ 35 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -6,14 +6,12 @@ import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientAimSports;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientHealthStandardDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.task.HealthIndexUploadTask;
@ -40,6 +38,7 @@ import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import org.springside.modules.utils.Clock;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@ -59,22 +58,20 @@ public class PatientHealthIndexService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DoctorWorkTimeService doctorWorkTimeService;
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientAimSportsDao patientAimSportsDao;
@ -724,7 +721,36 @@ public class PatientHealthIndexService extends BaseService {
                }
                case "3": {
                    obj.setType(3);
                    obj.setValue1(map.get("weight")); //体重
                    String weight = map.get("weight");
                    String height = map.get("height");
                    obj.setValue1(weight); //体重
                    obj.setValue2(height); //身高
                    PatientAimSports patientAimSports = new PatientAimSports();
                    patientAimSports = patientAimSportsDao.getPatientAimSportsByPatientCode(patientCode);
                    //如果该患者没有设置运动目标,则获取预置数据
                    if(patientAimSports == null || StringUtils.isBlank(patientAimSports.getCode())){
                        patientAimSports = patientAimSportsDao.findByCode("default");
                    }
                    double bmi = CommonUtil.getBMIByWeightAndHeight(map.get("weight"),map.get("height"));
                    DecimalFormat df1 = new DecimalFormat("###.00");
                    obj.setValue3(df1.format(bmi));
                    if(patientAimSports != null && StringUtils.isNoneEmpty(patientAimSports.getCode())){
                        //设置BMI值
                        if(bmi < Double.parseDouble(patientAimSports.getBmiMin())){
                            obj.setValue4("1");
                        }else if(bmi > Double.parseDouble(patientAimSports.getBmiMax())){
                            obj.setValue4("-1");
                        }else{
                            obj.setValue4("0");
                        }
                    }
                    break;
                }
                case "4": {

+ 22 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.*;
import java.text.DecimalFormat;
@Component
public class CommonUtil {
    @Value("${fastDFS.fastdfs_file_url}")
@ -347,5 +349,25 @@ public class CommonUtil {
        return null;
    }
    /**
     * 传入身高体重,计算BMI值
     * @param weightStr 体重
     * @param heightStr 身高
     * @return
     */
    public double getBMIByWeightAndHeight(String weightStr,String heightStr){
        DecimalFormat df2 = new DecimalFormat("###.00");
        double weight = Double.parseDouble(weightStr);
        Integer heightCM = Integer.parseInt(heightStr);
        heightStr = df2.format(heightCM/100d);
        double height = Double.parseDouble(heightStr);
        double bmi = weight / height * 2;
        return bmi;
    }
}

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java

@ -44,6 +44,8 @@ public class BaseController {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            logger.info("json:"+json.toString());
            System.out.println("json:"+json.toString());
            return json.getString("uid");
        } catch (Exception e) {

+ 62 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
@ -15,6 +16,7 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
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;
@ -25,6 +27,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.DateFormat;
@ -75,4 +78,63 @@ public class PatientInfoController extends BaseController {
            return invalidUserException(e, -1, "获取患者信息失败!");
        }
    }
    @RequestMapping(value = "createProfile",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("档案建立")
    @ObserverRequired
    public String createProfile(@ApiParam(value = "医生code", name = "doctorCode") @RequestParam(required = true)String doctorCode ,
                                @ApiParam(value = "患者code", name = "patient") @RequestParam(required = true)String patient,
                                @ApiParam(value = "居委会", name = "jwCountryCode") @RequestParam(required = true)String jwCountryCode,
                                @ApiParam(value = "民族", name = "nation") @RequestParam(required = true)String nation,
                                @ApiParam(value = "血型", name = "blood") @RequestParam(required = true)String blood,
                                @ApiParam(value = "婚姻状况", name = "marry") @RequestParam(required = true)String marry){
        try {
            // 获取医生下的患者
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient, jwCountryCode, nation, blood, marry));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取患者信息失败!");
        }
    }
    @RequestMapping(value = "getNationDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取民族信息列表")
    public String getNationDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getNationDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getMarryDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("婚姻状态字典")
    public String getMarryDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getMarryDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getBloodDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("血型状态字典")
    public String getBloodDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getBloodDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
}

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java

@ -20,6 +20,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -47,7 +49,7 @@ public class GcDoctorController extends BaseController {
    @Autowired
    private FamilyContractService familyContractService;
    private Logger logger = LoggerFactory.getLogger(GcDoctorController.class);
    @RequestMapping(value = "/doctor", method = RequestMethod.GET)
    @ApiOperation("根据医生code查询医生信息")
    public ResultOneModel<DoctorModel> doctor(
@ -106,7 +108,9 @@ public class GcDoctorController extends BaseController {
    @ApiOperation("获取医生所属团队")
    public ResultListModel<AdminTeamModel> doctors(
    ) {
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());
        logger.info("getUID:"+getUID());
        System.out.println("getUID:"+getUID());
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());//hxmD201703150222"
        List<AdminTeamModel> adminTeamModelList = new ArrayList<>();
        if (teams != null && teams.size() > 0) {
            teams.stream().forEach(one -> {

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -183,7 +183,7 @@ public class GcEduArticleService {
        }
        //保存到ES中
        //elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        elastricSearchSave.save(healthEduArticlePatients, esIndex, esType);
        return healthEduArticlePatients;
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -13,7 +13,7 @@ spring:
      password: 123456
  redis:
    host: 172.19.103.47 # Redis server host.
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr