Переглянути джерело

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

lyr 8 роки тому
батько
коміт
ec305c33ad

+ 46 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java

@ -1,13 +1,12 @@
package com.yihu.wlyy.entity.patient;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import java.util.Date;
/**
 * 预约挂号记录表
@ -64,6 +63,14 @@ public class PatientReservation extends IdEntity {
	private String doctorJob;
	// 状态:1预约成功,0预约取消
	private Integer status;
	//取消预约者(状态为预约取消时才有值)
	private String canceler;
	//取消预约者姓名(状态为预约取消时才有值)
	private String cancelerName;
	//取消预约者角色(状态为预约取消时才有值)1专科医生,2全科医生,3健康管理师,4临时专科 5.患者 (与医生服务团队角色一直)
	private Integer cancelerType;
	//取消时间(状态为预约取消时才有值)
	private String cancelerTime;
	// 预约时间
	private Date czrq;
	// 0 健康之路 1智业
@ -244,6 +251,41 @@ public class PatientReservation extends IdEntity {
		this.status = status;
	}
	public String getCanceler() {
		return canceler;
	}
	public void setCanceler(String canceler) {
		this.canceler = canceler;
	}
	@Column(name = "canceler_name")
	public String getCancelerName() {
		return cancelerName;
	}
	public void setCancelerName(String cancelerName) {
		this.cancelerName = cancelerName;
	}
	@Column(name = "canceler_type")
	public Integer getCancelerType() {
		return cancelerType;
	}
	public void setCancelerType(Integer cancelerType) {
		this.cancelerType = cancelerType;
	}
	@Column(name = "canceler_time")
	public String getCancelerTime() {
		return cancelerTime;
	}
	public void setCancelerTime(String cancelerTime) {
		this.cancelerTime = cancelerTime;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientReservationDao.java

@ -5,6 +5,7 @@
 *******************************************************************************/
package com.yihu.wlyy.repository.patient;
import java.util.Date;
import java.util.List;
import org.springframework.data.domain.Page;
@ -29,4 +30,8 @@ public interface PatientReservationDao extends PagingAndSortingRepository<Patien
	@Query("select count(1) from PatientReservation a where a.doctor = ?1 and a.patient=?2 ")
	Long  countReservationByDoctorForPatient(String doctor,String patient);
	@Query(value = "select a.* from wlyy_patient_reservation a where a.patient = ?1 and a.canceler=?2 and a.canceler_time>?3 and a.status ='0' order by a.canceler_time DESC limit 1",nativeQuery = true)
	PatientReservation findByPatientAndCancelerAndCancelTime(String patient,String canceler,String cancelerTime);
}

+ 51 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reservation/PatientReservationService.java

@ -1,14 +1,21 @@
package com.yihu.wlyy.service.app.reservation;
import java.util.*;
import javax.transaction.Transactional;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.entity.patient.PatientReservationDoctor;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.repository.patient.PatientReservationDoctorDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -23,12 +30,8 @@ import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.entity.patient.PatientReservationDoctor;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.repository.patient.PatientReservationDoctorDao;
import com.yihu.wlyy.service.BaseService;
import javax.transaction.Transactional;
import java.util.*;
/**
 * 预约挂号业务处理类
@ -52,7 +55,10 @@ public class PatientReservationService extends BaseService {
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private DoctorTeamMemberDao doctorTeamDoctor;
    @Autowired
    private DoctorDao doctorDao;
@ -91,6 +97,40 @@ public class PatientReservationService extends BaseService {
        }
    }
    /**
     * 医生取消预约
     */
    @Transactional
    public void doctorCancelOrder(Long id,String doctor) {
        PatientReservation obj = patientReservationDao.findOne(id);
        if (obj.getStatus()!=0) {
            obj.setStatus(0);
            String patient = obj.getPatient();
            SignFamily signFamily = signFamilyDao.findByPatient(patient);//得到患者的签约信息
            DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(), doctor);//得到服务团队的医生信息
            obj.setCanceler(doctorTeamMember.getMemberCode());
            obj.setCancelerName(doctorTeamMember.getName());
            obj.setCancelerType(doctorTeamMember.getType());
            obj.setCancelerTime(DateUtil.dateToStrLong(new Date()));
            patientReservationDao.save(obj);
        }
    }
    /**
     * 居民取消预约
     */
    @Transactional
    public void patientCancelOrder(Long id,String patient) {
        PatientReservation obj = patientReservationDao.findOne(id);
        if (obj.getStatus()!=0) {
            obj.setCanceler(patient);
            obj.setCancelerName(obj.getName());
            obj.setCancelerType(5);
            obj.setCancelerTime(DateUtil.dateToStrLong(new Date()));
            patientReservationDao.save(obj);
        }
    }
    /**
     * 保存预约挂号记录
     *

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -420,6 +420,16 @@ public class DateUtil {
		return dateToStrShort(c.getTime());
	}
	/**
	 * 获取本月第一天
	 * @return
     */
	public static String getCurMonthFirstDayShort(){
		Calendar c = Calendar.getInstance();
		c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
		return dateToStrShort(c.getTime());
	}
	/**
	 * 判断是否润年
	 * 

+ 96 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/booking/DoctorBookingController.java

@ -0,0 +1,96 @@
package com.yihu.wlyy.web.doctor.booking;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.repository.patient.PatientReservationDao;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
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.springframework.beans.factory.annotation.Autowired;
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;
/**
 * 预约挂号
 * Created by yeshijie on 2017/2/4.
 */
@Controller
@RequestMapping(value = "/doctor/guahao")
@Api(description = "预约挂号接口-医生端")
public class DoctorBookingController extends BaseController{
    @Autowired
    private GuahaoXMService guahaoXM;
    @Autowired
    private GuahaoYihuService guahaoYihu;
    @Autowired
    private PatientReservationService patientReservationService;
    @Autowired
    private PatientReservationDao patientReservationDao;
    @RequestMapping(value = "isCancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("医生是否可取消代预约")
    public String cancelOrderDt(@ApiParam(name = "orderId", value = "订单id", defaultValue = "48")
                                @RequestParam(value = "orderId", required = true) Long orderId){
        try{
            PatientReservation obj = patientReservationService.findById(orderId);
            if(obj != null){
                PatientReservation pr = patientReservationDao.findByPatientAndCancelerAndCancelTime(obj.getPatient(),getUID(), DateUtil.getCurMonthFirstDayShort());//"6c0cfe5065e011e69f7c005056850d66"
                if(pr == null){
                    return write(200,"查询成功","status","1");//取消预约次数将计入居民取消次数,居民每月取消超过3次将纳入黑名单。是否继续撤销?
                }else{
                    return write(200,"查询成功","status","0");//对不起,您本月已取消过该居民预约,如需继续撤销,请让居民自行处理
                }
            }else{
                return error(-1, "挂号单不存在!");
            }
        }catch (Exception e){
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("取消挂号单")
    public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "48")
                              @RequestParam(value = "orderId", required = true) Long orderId) {
        try {
            //获取订单信息
            PatientReservation obj = patientReservationService.findById(orderId);
            boolean re = false;
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                if (type.equals("0")) {  //医护网接口
                    re = guahaoYihu.CancelOrder(code);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    re = guahaoXM.CancelOrder(code, obj.getSsc());
                }
            }
            if (re) {
                //更新状态
                patientReservationService.doctorCancelOrder(orderId,getUID());//"6c0cfe5065e011e69f7c005056850d66"
                return write(200, "取消挂号单成功!");
            } else {
                return error(-1, "取消挂号单失败!");
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
}

+ 85 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/booking/PatientBookingController.java

@ -0,0 +1,85 @@
package com.yihu.wlyy.web.patient.booking;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.service.app.reservation.PatientReservationService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
 * 预约挂号
 * Created by yeshijie on 2017/2/4.
 */
@Controller
@RequestMapping(value = "/patient/guahao")
@Api(description = "预约挂号接口-居民端")
public class PatientBookingController extends WeixinBaseController{
    @Autowired
    private GuahaoXMService guahaoXM;
    @Autowired
    private GuahaoYihuService guahaoYihu;
    @Autowired
    private PatientReservationService patientReservationService;
    @Autowired
    private PatientService patientService;
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("取消挂号单")
    public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "48")
                              @RequestParam(value = "orderId", required = true) Long orderId) {
        try {
            //获取订单信息
            PatientReservation obj = patientReservationService.findById(orderId);
            boolean re = false;
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                if (type.equals("0")) {  //医护网接口
                    re = guahaoYihu.CancelOrder(code);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    re = guahaoXM.CancelOrder(code, obj.getSsc());
                }
            }
            if (re) {
                //更新状态
                patientReservationService.patientCancelOrder(orderId,getUID());//"9aa5c557e06a4324911487a035195545"
                //微信消息
                Patient p = patientService.findByCode(obj.getPatient());
                if (StringUtils.isNotEmpty(p.getOpenid())) {
                    JSONObject json = new JSONObject();
                    json.put("first", "");
                    json.put("toUser", p.getCode());
                    json.put("name", obj.getName());
                    json.put("date", obj.getStartTime());
                    json.put("doctorName", obj.getDoctorName());
                    json.put("orgName", obj.getOrgName());
                    json.put("remark", obj.getName() + ",您好!\n您已取消了" + obj.getStartTime() + "的挂号!");
                    PushMsgTask.getInstance().putWxMsg(getAccessToken(), 7, p.getOpenid(), obj.getName(), json);
                }
                return write(200, "取消挂号单成功!");
            } else {
                return error(-1, "取消挂号单失败!");
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }
}