Browse Source

产检和im修改

yeshijie 7 years ago
parent
commit
9e9271d593

+ 112 - 114
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -786,72 +786,71 @@ public class ConsultTeamService extends ConsultService {
     * @throws Exception
     */
    public int addTeamConsult(ConsultTeam ct, String patient,String agent) throws Exception {
        if (exist(patient, ct.getType())) {//判断是否有未结束的咨询移到同步方法中
            return -3;
        }
        synchronized (patient.intern()){//新增同步块,防止居民网络不好时多次点击,或者im服务器响应慢导致同时发起多个咨询
            if (exist(patient, ct.getType())) {//判断是否有未结束的咨询移到同步方法中
                return -3;
            }
        JSONObject users = new JSONObject();
            JSONObject users = new JSONObject();
        if(patient.equals(agent)){
            agent = null;
        }
            if(patient.equals(agent)){
                agent = null;
        // 咨询三师
        if (ct.getType() == 1) {
            // 查询三师签约信息
            SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
            if (sc == null) {
                // 不存在三师签约
                return -2;
            }
            // 咨询三师
            if (ct.getType() == 1) {
                // 查询三师签约信息
                SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
                if (sc == null) {
                    // 不存在三师签约
                    return -2;
                }
                ct.setTeam(sc.getTeamCode());
                // 设置健康管理师,三师咨询默认给健康管理师处理
                //查找病人所在的团队
                DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
                //得到团队的健康管理师
                DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
                DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
                if (doctorTeamMemberHealthy == null) {
                    ct.setDoctor(doctorTeamMember.getMemberCode());
                    users.put(doctorTeamMember.getMemberCode(), 0);
                } else {
                    users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
                    if (doctorTeamMember != null) {
                        if (users.isNull(doctorTeamMember.getMemberCode())) {
                            users.put(doctorTeamMember.getMemberCode(), 1);
                        }
            ct.setTeam(sc.getTeamCode());
            // 设置健康管理师,三师咨询默认给健康管理师处理
            //查找病人所在的团队
            DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
            //得到团队的健康管理师
            DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            if (doctorTeamMemberHealthy == null) {
                ct.setDoctor(doctorTeamMember.getMemberCode());
                users.put(doctorTeamMember.getMemberCode(), 0);
            } else {
                users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
                if (doctorTeamMember != null) {
                    if (users.isNull(doctorTeamMember.getMemberCode())) {
                        users.put(doctorTeamMember.getMemberCode(), 1);
                    }
                    ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
                }
                // 设置家庭医生
                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
            }
            // 设置家庭医生
                ct.setAdminTeamId(sc.getAdminTeamId());
            } else if (ct.getType() == 2) {
                // 咨询家庭医生
                SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
            ct.setAdminTeamId(sc.getAdminTeamId());
        } else if (ct.getType() == 2) {
            // 咨询家庭医生
            SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
                if (sf == null) {
                    // 不存在家庭签约
                    return -1;
                }
                ct.setTeam(sf.getTeamCode());
                // 设置健康管理师,家庭医生咨询默认给健康管理师处理
                //查找病人所在的团队
                //1.3.3.2 更改从签约记录判断团队成员,分配建管师
                if(StringUtils.isNotBlank(sf.getDoctorHealth())) {
                    users.put(sf.getDoctorHealth(), 0);
                    ct.setDoctor(sf.getDoctorHealth());
                    if (StringUtils.isNotBlank(sf.getDoctor())) {
                        if (users.isNull(sf.getDoctor())) {
                            users.put(sf.getDoctor(), 1);
                        }
            if (sf == null) {
                // 不存在家庭签约
                return -1;
            }
            ct.setTeam(sf.getTeamCode());
            // 设置健康管理师,家庭医生咨询默认给健康管理师处理
            //查找病人所在的团队
            //1.3.3.2 更改从签约记录判断团队成员,分配建管师
            if(StringUtils.isNotBlank(sf.getDoctorHealth())) {
                users.put(sf.getDoctorHealth(), 0);
                ct.setDoctor(sf.getDoctorHealth());
                if (StringUtils.isNotBlank(sf.getDoctor())) {
                    if (users.isNull(sf.getDoctor())) {
//                        users.put(sf.getDoctor(), 1); 全科默认也收到消息
                        users.put(sf.getDoctor(), 0);
                    }
                } else {
                    ct.setDoctor(sf.getDoctor());
                    users.put(sf.getDoctor(), 0);
                }
            } else {
                ct.setDoctor(sf.getDoctor());
                users.put(sf.getDoctor(), 0);
            }
//            DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
//            //得到团队的健康管理师
@ -871,69 +870,68 @@ public class ConsultTeamService extends ConsultService {
//                ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
//            }
                // 设置家庭医生
                ct.setAdminTeamId(sf.getAdminTeamId());
            }
            // 设置患者信息
            ct.setPatient(patient);
            // 查询患者信息
            Patient tempPatient = patientDao.findByCode(patient);
            // 设置患者姓名
            ct.setName(tempPatient.getName());
            // 设置患者生日
            ct.setBirthday(tempPatient.getBirthday());
            //新增性别
            ct.setSex(tempPatient.getSex());
            // 设置患者头像
            ct.setPhoto(tempPatient.getPhoto());
            // 设置操作日期
            ct.setCzrq(new Date());
            ct.setDel("1");
            ct.setStatus(0);
            ct.setEvaluate(0);
            // 医生未读数量为1
            ct.setDoctorRead(1);
            // 添加咨询记录
            Consult consult = addConsult(ct.getPatient(), null, ct.getSymptoms(), ct.getImages(), ct.getType());
            // 设置关联指导
            consult.setGuidance(ct.getGuidance());
            // 设置咨询标识
            ct.setConsult(consult.getCode());
            // 设置家庭医生
            ct.setAdminTeamId(sf.getAdminTeamId());
        }
        // 设置患者信息
        ct.setPatient(patient);
        // 查询患者信息
        Patient tempPatient = patientDao.findByCode(patient);
        // 设置患者姓名
        ct.setName(tempPatient.getName());
        // 设置患者生日
        ct.setBirthday(tempPatient.getBirthday());
        //新增性别
        ct.setSex(tempPatient.getSex());
        // 设置患者头像
        ct.setPhoto(tempPatient.getPhoto());
        // 设置操作日期
        ct.setCzrq(new Date());
        ct.setDel("1");
        ct.setStatus(0);
        ct.setEvaluate(0);
        // 医生未读数量为1
        ct.setDoctorRead(1);
        // 添加咨询记录
        Consult consult = addConsult(ct.getPatient(), null, ct.getSymptoms(), ct.getImages(), ct.getType());
        // 设置关联指导
        consult.setGuidance(ct.getGuidance());
        // 设置咨询标识
        ct.setConsult(consult.getCode());
            //推送给IM去创建议题,取得成员消息
        //推送给IM去创建议题,取得成员消息
//        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), "咨询问题:"+consult.getSymptoms(), consult.getImages());
            JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(),agent);
            users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
            JSONObject obj = ImUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
            if (obj == null) {
                throw new RuntimeException("IM消息发送异常!");
            }
            if(obj.getInt("status")==-1){//im议题创建失败
                throw new RuntimeException(obj.getString("message"));
            }
            ct.setStartMsgId(obj.get("start_msg_id").toString());
            consultTeamDao.save(ct);
            consultDao.save(consult);
            for (String key : users.keySet()) {
                if (patient.equals(key)) {
                    continue;
                }
                //记录咨询的医生详情误删
                ConsultTeamDoctor cd = new ConsultTeamDoctor();
                cd.setConsult(consult.getCode());
                cd.setDel("1");
                cd.setCzrq(new Date());
                cd.setTo(key);
                consultTeamDoctorDao.save(cd);
        JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(),agent);
        users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
        JSONObject obj = ImUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
        if (obj == null) {
            throw new RuntimeException("IM消息发送异常!");
        }
        if(obj.getInt("status")==-1){//im议题创建失败
            throw new RuntimeException(obj.getString("message"));
        }
        ct.setStartMsgId(obj.get("start_msg_id").toString());
        consultTeamDao.save(ct);
        consultDao.save(consult);
        for (String key : users.keySet()) {
            if (patient.equals(key)) {
                continue;
            }
            //记录咨询的医生详情误删
            ConsultTeamDoctor cd = new ConsultTeamDoctor();
            cd.setConsult(consult.getCode());
            cd.setDel("1");
            cd.setCzrq(new Date());
            cd.setTo(key);
            consultTeamDoctorDao.save(cd);
        }
            // 保存医生咨询信息
            // 添加咨询转发记录
            // 添加医生咨询日志
            String content = addLogs(ct);
        // 保存医生咨询信息
        // 添加咨询转发记录
        // 添加医生咨询日志
        String content = addLogs(ct);
            return 1;
        }
        return 1;
    }
    /**

+ 43 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -2,15 +2,18 @@ package com.yihu.wlyy.service.app.prenatalInspector;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlanLibrary;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPreCard;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.third.jw.JwMaternalChildService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
@ -18,6 +21,8 @@ import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -34,6 +39,8 @@ import java.util.Map;
@Transactional(rollbackFor = Exception.class)
public class PrenatalInspectorPreCardService extends BaseService {
    private static Logger logger = LoggerFactory.getLogger(PrenatalInspectorPreCardService.class);
    @Autowired
    private PrenatalInspectorPreCardDao prenatalInspectorPreCardDao;
    @Autowired
@ -56,6 +63,10 @@ public class PrenatalInspectorPreCardService extends BaseService {
    private DoctorDao doctorDao;
    @Autowired
    private ZyDictService zyDictService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    @Autowired
    private DevicePatientHealthIndexDao healthIndexDao;
//    public
@ -164,7 +175,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
                        //计算距离下次产检时间
                        Long nextExamDay = 0l;
                        for (PrenatalInspectorPlan plan:plans) {
                            Long temp = DateUtil.getDays(date,plan.getInspectionTime());
                            Long temp = DateUtil.getDays(plan.getInspectionTime(),date);
                            if(nextExamDay==0||nextExamDay>temp){
                                nextExamDay = temp;
                            }
@ -249,7 +260,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
                            //计算距离下次产检时间
                            Long nextExamDay = 0l;
                            for (PrenatalInspectorPlan plan:plans) {
                                Long temp = DateUtil.getDays(date,plan.getInspectionTime());
                                Long temp = DateUtil.getDays(plan.getInspectionTime(),date);
                                if(nextExamDay==0||nextExamDay>temp){
                                    nextExamDay = temp;
                                }
@ -521,9 +532,9 @@ public class PrenatalInspectorPreCardService extends BaseService {
     * 新建产检预建卡
     */
    @Transactional
    public String addPrenatalInspectorPreCard(PrenatalInspectorPreCard preCard,String patientcCode){
    public String addPrenatalInspectorPreCard(PrenatalInspectorPreCard preCard,String patientCode){
        SignFamily signFamily = signFamilyDao.findByPatient(patientcCode);
        SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
        if(signFamily==null){
            return "-1";
        }
@ -596,4 +607,32 @@ public class PrenatalInspectorPreCardService extends BaseService {
        return preCard.getCode();
    }
    /**
     * 保存体征数据 有保存体征数据才更新
     * @param preCard
     * @param patientCode
     */
    public void saveHealthIndex(PrenatalInspectorPreCard preCard,String patientCode){
        if(StringUtils.isNotBlank(preCard.getHeight())&&StringUtils.isNotBlank(preCard.getWeight())){
            //先判断体征数据是否变更
            DevicePatientHealthIndex index = healthIndexDao.findLastData(patientCode, 3);
            String height = index.getValue2();
            String weight = index.getValue1();
            if(!preCard.getHeight().equals(height)||!preCard.getWeight().equals(weight)){
                //更新体征数据
                JSONObject json = new JSONObject();
                json.put("time",DateUtil.dateToStrLong(preCard.getCzrq()));
                json.put("height",preCard.getHeight());
                json.put("weight",preCard.getWeight());
                try {
                    healthIndexService.addPatientHealthIndex(json.toString(), "3", patientCode, null);
                }catch (Exception e){
                    e.printStackTrace();
                    logger.error("预建卡时 保存体征数据失败。。。");
                }
            }
        }
    }
}

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/PrenatalInspectorContoller.java

@ -41,7 +41,8 @@ public class PrenatalInspectorContoller extends BaseController{
            if("-1".equals(code)){
                return error(-1,"居民未签约,无法添加预建卡信息");
            }
            String re = preCardService.uploadPreExam(code);
            preCardService.saveHealthIndex(preCard,getRepUID());//保存体征数据
            String re = preCardService.uploadPreExam(code);//上传智业
            if(StringUtils.isNotBlank(re)){
                System.out.println("re======"+re);
                return error(-1,re);