Explorar o código

Merge branch 'dev' of yeshijie/patient-co-management into dev

chenweida %!s(int64=7) %!d(string=hai) anos
pai
achega
0c914bcf4a

+ 10 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/Consult.java

@ -43,7 +43,8 @@ public class Consult extends IdEntity {
	// 结束时间
	private Date endTime;
	//签约表Code
	private String  signCode;
	private String signCode;
	private String relationCode;//关联业务表的code
	public String getCode() {
		return code;
@ -133,4 +134,12 @@ public class Consult extends IdEntity {
	public void setSignCode(String signCode) {
		this.signCode = signCode;
	}
	public String getRelationCode() {
		return relationCode;
	}
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
}

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java

@ -57,6 +57,8 @@ public class ConsultTeam extends IdEntity {
	//评价时间
	private Date evaluateTime;
	private String relationCode;//关联业务表的code
	public Integer getEvaluate() {
		return evaluate;
	}
@ -315,4 +317,12 @@ public class ConsultTeam extends IdEntity {
	public void setEndType(Integer endType) {
		this.endType = endType;
	}
	public String getRelationCode() {
		return relationCode;
	}
	public void setRelationCode(String relationCode) {
		this.relationCode = relationCode;
	}
}

+ 12 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java

@ -13,19 +13,19 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
    Consult findByCode(String code);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type<>8 and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1' and a.type<>8 and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, long id, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type<>8 order by a.czrq desc")
    Page<Object> findByPatient(String patient, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1' and a.type<>8 order by a.czrq desc")
    Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
    @Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")
@ -37,4 +37,12 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
    //获取咨询的状态
    @Query("select a from Consult a,ConsultTeam b where a.code = b.consult and a.code = ?1 ")
    Consult findTypeByCode(String code);
    // 按类型查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.evaluate,a.relationCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1' and a.type=?3 order by a.czrq desc")
    Page<Object> findByPatientAndType(String patient, long id,Integer type,Pageable pageRequest);
    // 按类型查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.evaluate,a.relationCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type=?2 order by a.czrq desc")
    Page<Object> findByPatientAndType(String patient,Integer type, Pageable pageRequest);
}

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

@ -19,4 +19,7 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Modifying
    @Query("update Prescription p set p.status=?2 where p.code=?1")
    void updateStatus(String prescriptionCode,Integer status);
    @Query("select p from Prescription p where p.jwCode=?1 and p.status=?2 ")
    List<Prescription> fingdByJwCodeAndStatus(String jwcode,Integer status);
}

+ 22 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java

@ -110,6 +110,28 @@ public class ConsultService extends BaseService {
		}
	}
	/**
	 * 按类型查找居民的咨询记录
	 * @return
     */
	public Page<Object> findConsultRecordByType(String patient,long id,int pagesize,Integer type,String title){
		if (id < 0) {
			id = 0;
		}
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		if (id > 0) {
			return consultDao.findByPatientAndType(patient, id,type, pageRequest);
		} else {
			return consultDao.findByPatientAndType(patient,type, pageRequest);
		}
	}
	public Consult findOneConsult(String consult) {
		return consultDao.findByCode(consult);
	}

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

@ -32,6 +32,7 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.*;
@ -109,6 +110,8 @@ public class ConsultTeamService extends ConsultService {
    private MessageDao messageDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    WeiXinAccessTokenUtils accessTokenUtils;
@ -855,6 +858,11 @@ public class ConsultTeamService extends ConsultService {
        synchronized (jwCode.intern()){
            List<Prescription> prescriptionList = prescriptionDao.fingdByJwCodeAndStatus(jwCode,0);
            if(prescriptionList!=null&&prescriptionList.size()>0){//存在未审核的续方
                return -1;
            }
            Doctor doctor = doctorDao.findByCode(doctorCode);
            // 查询患者信息
            Patient p = patientDao.findByCode(patient);
@ -897,7 +905,9 @@ public class ConsultTeamService extends ConsultService {
            if(patient.equals(agent)){
                agent = null;
            }
            //关联业务code
            ct.setRelationCode(prescription.getCode());
            //医生信息
            ct.setDoctor(doctorCode);
            ct.setDoctorName(doctor.getName());
            // 设置患者信息
@ -919,8 +929,8 @@ public class ConsultTeamService extends ConsultService {
            ct.setDoctorRead(1);
            // 添加咨询记录
            Consult consult = addConsult(ct.getPatient(), null, ct.getSymptoms(), ct.getImages(), ct.getType());
            // 设置关联指导
            consult.setGuidance(ct.getGuidance());
            //关联业务code
            consult.setRelationCode(prescription.getCode());
            // 设置咨询标识
            ct.setConsult(consult.getCode());
@ -957,10 +967,12 @@ public class ConsultTeamService extends ConsultService {
            // 添加医生咨询日志
            String content = addLogs(ct);
            prescriptionLogService.addLog(prescription,3,1,1);
            return 1;
        }
    }
    /**
     * 发送消息给IM
     *

+ 30 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionLogService.java

@ -1,11 +1,13 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
@ -26,4 +28,32 @@ public class PrescriptionLogService extends BaseService {
    public List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] types) {
        return prescriptionLogDao.findPrescriptionLogsByPrescriptionCode(prescriptionCode, types);
    }
    /**
     * 添加日志
     * @param prescription
     * @param type 类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
     * @param flag 1成功 0失败
     * @param userType 1 患者 2医生
     */
    public void addLog(Prescription prescription,Integer type,Integer flag,Integer userType){
        PrescriptionLog log = new PrescriptionLog();
        log.setStatus(prescription.getStatus());
        log.setType(type);
        log.setCode(getCode());
        log.setCreateTime(new Date());
        log.setFlag(flag);
        log.setHospital(prescription.getHospital());
        log.setHospitalName(prescription.getHospitalName());
        log.setPrescriptionCode(prescription.getCode());
        if(userType==1){
            log.setUserCode(prescription.getParentCode());
            log.setUserName(prescription.getPatientName());
        }else {
            log.setUserCode(prescription.getDoctor());
            log.setUserName(prescription.getDoctorName());
        }
        log.setUserType(userType);
        prescriptionLogDao.save(log);
    }
}

+ 54 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -11,6 +11,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.consult.DoctorCommentService;
import com.yihu.wlyy.service.app.prescription.PrescriptionDiagnosisService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.DoctorStatisticsService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
@ -66,6 +67,8 @@ public class ConsultController extends WeixinBaseController {
    private SignFamilyDao signFamilyDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PrescriptionDiagnosisService prescriptionDiagnosisService;
    /**
     * 患者咨询记录查询
@ -124,6 +127,53 @@ public class ConsultController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "getPreConsultList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取续方咨询列表")
    public String getPreConsultList(@RequestParam(required = false) String title,
            @RequestParam(required = true) long id,@RequestParam(required = true) int pagesize){
        try {
            JSONArray array = new JSONArray();
//            Page<Object> data = consultTeamService.findConsultRecordByType("a663d0cf7f8c4d38a8327cedc921e65f", id, pagesize,8, title);//8表示续方咨询
            Page<Object> data = consultTeamService.findConsultRecordByType(getRepUID(), id, pagesize,8, title);//8表示续方咨询
            if (data != null) {
                for (Object consult : data.getContent()) {
                    if (consult == null) {
                        continue;
                    }
                    Object[] result = (Object[]) consult;
                    JSONObject json = new JSONObject();
                    json.put("id", result[0]);
                    // 设置咨询类型:1三师咨询,2视频咨询,3图文咨询,4公共咨询,5病友圈,8 续方咨询
                    json.put("type", result[1]);
                    // 设置咨询标识
                    json.put("code", result[2]);
                    // 设置显示标题
                    json.put("title", result[3]);
                    // 设置主诉
                    json.put("symptoms", result[4]);
                    // 咨询状态
                    json.put("status", result[6]);
                    // 设置咨询日期
                    json.put("czrq", DateUtil.dateToStrLong((Date) result[5]));
                    // 咨询状态
                    json.put("doctorCode", result[7]);
                    json.put("evaluate", result[8]);
                    String relationCode = result[9]==null?"":result[9].toString();
                    json.put("prescriptionCode",relationCode);//续方code
                    json.put("prescriptionDt",prescriptionDiagnosisService.getPrescriptionDiagnosis(relationCode));//续方疾病类型
                    json.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(relationCode));//续方药品信息
                    array.put(json);
                }
            }
            return write(200, "查询成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    /**
     * 获取医生的排班时间
     *
@ -292,9 +342,7 @@ public class ConsultController extends WeixinBaseController {
    @RequestMapping(value = "addPrescriptionConsult",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("添加续方咨询")
    public String addPrescriptionConsult(@ApiParam(name = "patient", value = "居民code", defaultValue = "1")
                                         @RequestParam(value = "patient", required = true) String patient,
                                         @ApiParam(name = "jwCode", value = "基位处方code", defaultValue = "10")
    public String addPrescriptionConsult(@ApiParam(name = "jwCode", value = "基位处方code", defaultValue = "10")
                                         @RequestParam(value = "jwCode", required = true) String jwCode,
                                         @ApiParam(name = "doctor", value = "咨询医生(开方医生、审核医生)", defaultValue = "86225d1365e711e69f7c005056850d66")
                                         @RequestParam(value = "doctor", required = true) String doctor,
@ -307,10 +355,10 @@ public class ConsultController extends WeixinBaseController {
            consult.setType(8);//续方咨询
            consult.setAdminTeamId(adminTeamId);
            // 保存到数据库
            int res = consultTeamService.addPrescriptionConsult(jwCode, "a663d0cf7f8c4d38a8327cedc921e65f","a663d0cf7f8c4d38a8327cedc921e65f",doctor,consult,reason);
//            int res = consultTeamService.addPrescriptionConsult(jwCode, getRepUID(),getUID(),doctor,consult,reason);
//            int res = consultTeamService.addPrescriptionConsult(jwCode, "a663d0cf7f8c4d38a8327cedc921e65f","a663d0cf7f8c4d38a8327cedc921e65f",doctor,consult,reason);
            int res = consultTeamService.addPrescriptionConsult(jwCode, getRepUID(),getUID(),doctor,consult,reason);
            if (res == -1) {
                return error(-1, "家庭签约信息不存在或已过期,无法进行家庭医生咨询!");
                return error(-1, "该处方存在未审核的续方,无法进行续方咨询!");
            }
//            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());