Browse Source

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

chenweida 8 years ago
parent
commit
4929d8b72c

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -53,6 +53,9 @@ public interface DevicePatientHealthIndexDao
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate >= ?3 and a.recordDate <= ?4 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
	List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
	@Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 order by a.recordDate desc ")
	Iterable<DevicePatientHealthIndex> findRecentByPatient(String patient);

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -24,6 +24,6 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.creater = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByCreater(String creater, Date begin, Date end, Pageable pageRequest) throws Exception;
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code = ?1 and a.patient_code = ?2 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String doctorCode,String patientCode) throws Exception;
    @Query(value = "select a.* from wlyy_followup a where a.doctor_code in ?1 and a.patient_code = ?2 and a.followup_class=?3 and a.status ='1' order by a.followup_date DESC limit 1",nativeQuery = true)
    Followup findLastFollowup(String[] doctors,String patientCode,String followClass) throws Exception;
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/followup/FollowupContentDao.java

@ -18,4 +18,6 @@ public interface FollowupContentDao extends PagingAndSortingRepository<FollowupC
    List<String> findProjectByFollowupId(Long followupId) throws Exception;
    List<FollowupContent> findByFollowupIdAndFollowupProject(Long followupId,String followupProject);
    List<FollowupContent> findByFollowupId(Long followupId);
}

+ 95 - 20
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -9,10 +9,13 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.followup.FollowupContent;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.followup.FollowupContentDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.FollowupUploadTask;
import com.yihu.wlyy.util.DateUtil;
@ -55,6 +58,12 @@ public class FollowUpService extends BaseService {
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private SignFamilyDao signFamilyDao;
	@Autowired
	private DrHealthTeamService drHealthTeamService;
	/**
	 * 转译随访信息
     */
@ -400,26 +409,6 @@ public class FollowUpService extends BaseService {
	}
	/**
	 * 获取上次随访项目数据
	 */
	public Map<String,String> getLastFollowupProjectData(String doctor,String patient,String followupProject) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		Followup lastFollowup = followupDao.findLastFollowup(doctor,patient);
		if(lastFollowup!=null)
		{
			List<FollowupContent> dataList =  followupContentDao.findByFollowupIdAndFollowupProject(lastFollowup.getId(),followupProject);
			for(FollowupContent item:dataList)
			{
				re.put(item.getFollowupKey(),item.getFollowupValue());
			}
		}
		return re;
	}
	/**
	 *保存面访项目数据
	 */
@ -484,4 +473,90 @@ public class FollowUpService extends BaseService {
	}
	/*************************************** 上次随访 ********************************************/
	/**
	 * 获取团队医生
     */
	private List<Doctor>  getTeamDoctors(String doctor,String patient) throws Exception
	{
		List<Doctor> doctors = new ArrayList<>();
		//获取医生团队成员
		SignFamily signFamily = signFamilyDao.findByFamilyDoctorAndPatient(doctor, patient);
		// 查询家庭医生团队
		if (signFamily != null) {
			doctors = drHealthTeamService.findTeamDoctors(signFamily.getTeamCode());
		}
		// 查询三师团队医生
		if (doctors == null || doctors.size() == 0) {
			SignFamily sanshiSign = signFamilyDao.findBySanshiDoctorAndPatient(doctor, patient);
			if (sanshiSign != null) {
				doctors = drHealthTeamService.findTeamDoctors(patient, 1);
			} else {
				doctors = new ArrayList<>();
			}
		}
		return doctors;
	}
	/**
	 * 获取上次随访
	 */
	public Map<String,String> getLastFollowup(String doctor,String patient,String followClass) throws Exception
	{
		Map<String,String> re = new HashMap<>();
		//获取医生团队成员
		String[] doctors = new String[]{doctor};
		List<Doctor> doctorList = getTeamDoctors(doctor,patient);
		if(doctorList!=null&& doctorList.size()>1)
		{
			doctors = new String[doctorList.size()];
			for(int i=0;i<doctorList.size();i++)
			{
				doctors[i] = doctorList.get(i).getCode();
			}
		}
		//获取最新的随访记录
		Followup followup = followupDao.findLastFollowup(doctors,patient,followClass);
		if(followup!=null)
		{
			re.put("id",String.valueOf(followup.getId()));
			re.put("followupDate",DateUtil.dateToStrShort(followup.getFollowupDate()));
		}
		else{
			re = null;
		}
		return re;
	}
	/**
	 * 获取上次随访
	 */
	public void copyFollowup(Long id,Long fromId) throws Exception
	{
		List<FollowupContent> list = followupContentDao.findByFollowupId(fromId);
		if(list!=null && list.size()>0)
		{
			List<FollowupContent> copyList = new ArrayList<>();
			for (FollowupContent item :list)
			{
				FollowupContent copyItem = new FollowupContent();
				copyItem.setFollowupId(id);
				copyItem.setFollowupKey(item.getFollowupKey());
				copyItem.setFollowupValue(item.getFollowupKey());
				copyItem.setFollowupProject(item.getFollowupProject());
				copyItem.setCreateTime(new Date());
				copyList.add(copyItem);
			}
			followupContentDao.save(copyList);
		}
	}
}

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

@ -777,4 +777,69 @@ public class PatientHealthIndexService extends BaseService {
        }
    }
    /**
     * 获取患者健康指标历史记录
     * 1血糖,2血压,3体重,4腰围
     */
    public List<Map<String,String>> getHealthIndexHistory(String patientCode, int type,int page,int pagesize) throws Exception {
        List<Map<String, String>> re = new ArrayList<>();
        // 排序
        Sort sort = new Sort(Direction.DESC, "recordDate");
        PageRequest pageRequest = new PageRequest(page, pagesize, sort);
        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatient(patientCode, type, pageRequest);
        if (list != null && list.size() > 0) {
            for (DevicePatientHealthIndex item : list) {
                Map<String, String> map = new HashMap<>();
                if (type == 1)    //血糖
                {
                    String gi = item.getValue1();
                    String giType = item.getValue2();
                    map.put("time", DateUtil.dateToStrLong(item.getRecordDate()));
                    map.put("gi", gi); //  血糖值
                    map.put("gi_type", giType); //  血糖值类型
                    String text = gi + " mmol/L";
                    if ("1".equals(giType)) {
                        text += "(早餐前)";
                    } else if ("2".equals(giType)) {
                        text += "(早餐后)";
                    } else if ("3".equals(giType)) {
                        text += "(午餐前)";
                    } else if ("4".equals(giType)) {
                        text += "(午餐后)";
                    } else if ("5".equals(giType)) {
                        text += "(晚饭前)";
                    } else if ("6".equals(giType)) {
                        text += "(晚饭后)";
                    } else if ("7".equals(giType)) {
                        text += "(睡前)";
                    }
                    map.put("text", text); //  展示
                    re.add(map);
                } else if (type == 2) //血压
                {
                    String sys = item.getValue1();   //收缩压
                    String dia = item.getValue2();    //舒张压
                    String pul = item.getValue3();    //脉搏
                    map.put("time", DateUtil.dateToStrLong(item.getRecordDate()));
                    map.put("sys", sys);
                    map.put("dia", dia);
                    map.put("pul", pul);
                    re.add(map);
                } else if (type == 3) //体重
                {
                    String weight = item.getValue1();   //体重
                    map.put("time", DateUtil.dateToStrShort(item.getRecordDate()));
                    map.put("weight", weight);
                    map.put("text", weight + " kg");
                    re.add(map);
                }
            }
        }
        return re;
    }
}

+ 38 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java

@ -42,6 +42,25 @@ public class DoctorQuickReplyService extends BaseService {
        return quickReplyDao.save(reply);
    }
    /**
     * 修改快捷回复
     *
     * @param id      回复ID
     * @param content 快捷回复内容
     * @return
     */
    public DoctorQuickReply modifyReply(long id, String content) throws Exception {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        if (reply == null) {
            throw new Exception("reply not exist");
        }
        reply.setContent(content);
        return quickReplyDao.save(reply);
    }
    /**
     * 删除快捷回复
     *
@ -108,4 +127,23 @@ public class DoctorQuickReplyService extends BaseService {
        return 1;
    }
    /**
     * 排序回复
     *
     * @param id
     * @return
     */
    public int sortReplyList(String id) {
        String[] ids = id.split(",");
        for (int i = 0; i < ids.length; i++) {
            DoctorQuickReply reply = quickReplyDao.findOne(Long.valueOf(ids[i]));
            if (reply == null) {
                return -1;
            }
            reply.setSort(ids.length - i);
        }
        return 1;
    }
}

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

@ -1,12 +1,13 @@
package com.yihu.wlyy.service.app.reservation;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import javax.transaction.Transactional;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -39,21 +40,47 @@ public class PatientReservationService extends BaseService {
	private PatientReservationDao patientReservationDao;
	@Autowired
	private PatientReservationDoctorDao patientReservationDoctorDao;
	
	@Autowired
	private GuahaoXMService  guahaoXMService;
	@Autowired
	private ObjectMapper objectMapper;
	@Autowired
	private PatientDao patientDao;
	public PatientReservation findByCode(String code){
		return patientReservationDao.findByCode(code);
	}
	public PatientReservation findById(String id){
		return patientReservationDao.findById(Long.valueOf(id));
	public PatientReservation findById(Long id) throws Exception{
		PatientReservation re = patientReservationDao.findById(id);
		if(re==null)
		{
			throw new Exception("not exit result!id:"+id);
		}
		return re;
	}
	/**
	 * 实体转map
	 */
	private Map<String, String> entityToMap(PatientReservation obj) throws Exception {
		String mapString = objectMapper.writeValueAsString(obj);
		return objectMapper.readValue(mapString, Map.class);
	}
	/**
	 * 更新预约状态
     */
	public void updateStatus(String code,Integer status)
	@Transactional
	public void updateStatus(Long id,Integer status)
	{
		PatientReservation obj=  patientReservationDao.findByCode(code);
		PatientReservation obj=  patientReservationDao.findOne(id);
		if(!obj.getStatus().equals(status))
		{
			obj.setStatus(status);
@ -153,26 +180,93 @@ public class PatientReservationService extends BaseService {
	/**
	 * 分页获取患者预约记录,医生为空查患者所有
     */
	public List<PatientReservation> getReservationByPatient(String patient,String doctor, int page, int pagesize) {
	@Transactional
	public List<PatientReservation> getReservationByPatient(String patient,String doctor, int page, int pagesize) throws Exception
	{
		List<PatientReservation> list = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		if(StringUtils.isNotBlank(doctor)){//传入医生查询医生帮此患者的预约记录
			return patientReservationDao.findByPatientAndDoctor(patient, doctor, pageRequest);
			list = patientReservationDao.findByPatientAndDoctor(patient, doctor, pageRequest);
		}else{
			return patientReservationDao.findByPatient(patient, pageRequest);
			list = patientReservationDao.findByPatient(patient, pageRequest);
		}
		//更新当前状态
		if(list!=null)
		{
			//遍历更新预约状态
			for (PatientReservation item : list) {
				String type = item.getType();
				String code = item.getCode();
				if (type.equals("0")) {  //医护网接口
				}
				else if (type.equals("1"))   //厦门市民健康预约接口
				{
					Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
					//更新状态
					if (status != null && !status.equals(item.getStatus())) {
						item.setStatus(status);
					}
				}
			}
			patientReservationDao.save(list);
		}
		return list;
	}
	/**
	 * 分页获取患者预约记录(医生端)
	 */
	public List<PatientReservation> getReservationByDoctor(String doctor, int page, int pagesize) {
	public List<Map<String,String>> getReservationByDoctor(String doctor, int page, int pagesize) throws Exception
	{
		List<Map<String,String>> re = new ArrayList<>();
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		return patientReservationDao.findByDoctor(doctor, pageRequest);
		List<PatientReservation> list = patientReservationDao.findByDoctor(doctor, pageRequest);
		//更新当前状态
		if(list!=null)
		{
			//遍历更新预约状态
			for (PatientReservation item : list) {
				String type = item.getType();
				String code = item.getCode();
				if (type.equals("0")) {  //医护网接口
				}
				else if (type.equals("1"))   //厦门市民健康预约接口
				{
					Integer status = guahaoXMService.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
					//更新状态
					if (status != null && !status.equals(item.getStatus())) {
						item.setStatus(status);
					}
				}
			}
			patientReservationDao.save(list);
		}
		//返回患者头像
		for (PatientReservation item : list) {
			Map<String,String> map = entityToMap(item);
			Patient patient = patientDao.findByCode(item.getPatient());
			if(patient!=null){
				map.put("photo",patient.getPhoto());
			}
			re.add(map);
		}
		return re;
	}
	public Long countReservationByDoctorForPatient(String doctor,String patient){

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java

@ -103,7 +103,7 @@ public class PatientRemindService extends BaseService {
                    "     limit ?,3000";
            while (flag) {
                List<Patient> result = jdbcTemplate.query(sql,new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper<Patient>());
                List<Patient> result = jdbcTemplate.query(sql,new Object[]{doc.getCode(), doc.getCode(), start}, new BeanPropertyRowMapper(Patient.class));
                if (result != null && result.size() > 0) {
                    for (Patient p : result) {

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -614,6 +614,7 @@ public class GuahaoXMService implements IGuahaoService {
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        if (xml.toLowerCase().startsWith("ok")) {
            return true;
        } else {
            return false;
@ -953,7 +954,7 @@ public class GuahaoXMService implements IGuahaoService {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        else if (StringUtils.startsWith(xml, "Error")) {
        else if (StringUtils.startsWith(xml, "Error"))  {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }

+ 1 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSmjkService.java

@ -358,8 +358,7 @@ public class JwSmjkService {
            if (status == 200) {
                String data = jsonObject.getString("data");
                if (!StringUtils.isEmpty(data) && (data.startsWith("error")||data.startsWith("System-Error"))) {
                    return "111111|aaaaaa|zzzz";
                    //throw new Exception(data);
                    throw new Exception(data);
                } else {
                    re = data;
                }

+ 34 - 17
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -234,23 +234,6 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	@ApiOperation("获取上次随访项目数据")
	@RequestMapping(value = "/getLastFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowupProjectData(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
										 @RequestParam(value="patient",required = true) String patient,
										 @ApiParam(name="followupProject",value="随访项目",defaultValue = "2")
										 @RequestParam(value="followupProject",required = true) String followupProject)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowupProjectData("D20161008003",patient,followupProject);
			return write(200, "获取上次随访项目数据成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访项目数据失败!"+e.getMessage());
		}
	}
	@ApiOperation("保存随访项目数据")
	@RequestMapping(value = "/saveFollowupProjectData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
@ -302,4 +285,38 @@ public class DoctorFollowUpController extends BaseController {
		}
	}
	/*************************************** 上次随访 ********************************************/
	@ApiOperation("获取上次随访")
	@RequestMapping(value = "/getLastFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String getLastFollowup(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
								   @RequestParam(value="patient",required = true) String patient,
								   @ApiParam(name="followClass",value="随访类别",defaultValue = "1")
								   @RequestParam(value="followClass",required = true) String followClass)
	{
		try {
			Map<String,String> response = followUpService.getLastFollowup(getUID(),patient,followClass);
			return write(200, "获取上次随访成功!","data",response);
		} catch (Exception e) {
			return invalidUserException(e, -1, "获取上次随访失败!"+e.getMessage());
		}
	}
	@ApiOperation("复制上次随访数据")
	@RequestMapping(value = "/copyFollowup", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
	@ResponseBody
	public String copyFollowup(@ApiParam(name="id",value="本地随访ID",defaultValue = "")
								  @RequestParam(value="id",required = true) Long id,
								  @ApiParam(name="fromId",value="拷贝随访记录ID",defaultValue = "")
								  @RequestParam(value="fromId",required = true) Long fromId)
	{
		try {
			followUpService.copyFollowup(id,fromId);
			return write(200, "复制上次随访成功!");
		} catch (Exception e) {
			return invalidUserException(e, -1, "复制上次随访失败!"+e.getMessage());
		}
	}
}

+ 20 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -256,11 +256,6 @@ public class DoctorHealthController extends BaseController {
	}
	/**
	 * 根据患者标志获取健康指标
	 * @param patient 患者指标
	 * @return 操作结果
	 */
	@RequestMapping(value = "last",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("患者最新健康指标信息")
@ -285,4 +280,24 @@ public class DoctorHealthController extends BaseController {
		}
	}
	@RequestMapping(value = "getHealthIndexHistory",method = RequestMethod.GET)
	@ResponseBody
	@ApiOperation("获取患者健康指标历史记录")
	public String getHealthIndexHistory(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
										 @RequestParam(value="patient",required = true) String patient,
										 @ApiParam(name="type",value="指标类型1血糖,2血压,3体重,4腰围",defaultValue = "1")
										 @RequestParam(value="type",required = true) int type,
										 @ApiParam(name="page",value="第几页",defaultValue = "0")
										 @RequestParam(value="page",required = true) int page,
										 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
										 @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
			List<Map<String,String>> list = healthIndexService.getHealthIndexHistory(patient, type, page, pagesize);
			return write(200, "获取患者健康指标历史记录成功", "data", list);
		} catch (Exception ex) {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
}

+ 50 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java

@ -47,6 +47,31 @@ public class DoctorQuickReplyController extends BaseController {
        }
    }
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "修改快捷回复")
    public String modifyReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id,
                              @RequestParam @ApiParam(value = "快捷回复内容") String content) {
        try {
            if (id == null || id < 1) {
                return error(-1, "快捷回复ID不能为空");
            }
            if (StringUtils.isEmpty(content)) {
                return error(-1, "快捷回复内容不能为空");
            }
            DoctorQuickReply reply = quickReplyService.modifyReply(id, content);
            if (reply != null) {
                return write(200, "添加成功", "data", reply);
            } else {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除快捷回复")
    public String delReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id) {
@ -99,6 +124,31 @@ public class DoctorQuickReplyController extends BaseController {
        }
    }
    @RequestMapping(value = "/sortList", method = RequestMethod.POST)
    @ApiOperation(value = "快捷回复排序")
    public String sortReplyList(@RequestParam @ApiParam(value = "快捷回复ID")String id) {
        try {
            if (StringUtils.isEmpty(id)) {
                return error(-1, "请输入排序后的回复ID");
            }
            int result = quickReplyService.sortReplyList(id);
            if (result == 1) {
                return write(200, "排序成功");
            } else if (result == -1) {
                return error(-1, "快捷回复不存在或已删除");
            }  else if (result == -2) {
                return error(-1, "快捷回复已在排序位置");
            } else {
                return error(-1, "排序失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "排序失败");
        }
    }
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "快捷回复列表")
    public String replyList() {

+ 64 - 129
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -307,6 +307,54 @@ public class BookingController extends WeixinBaseController {
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("取消挂号单")
    public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
                              @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.updateStatus(orderId, 0);
                //微信消息
                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());
        }
    }
    /****************************************** 内网预约 ***************************************************************/
    @RequestMapping(value = "CreateOrderByDoctor", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("(内网)转诊预约挂号")
@ -390,12 +438,12 @@ public class BookingController extends WeixinBaseController {
    @ResponseBody
    @ApiOperation("(内网)获取医生排班接口")
    public String GetDoctorArrangeTenDay(
                                   @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
                                   @RequestParam(value = "hospitalId", required = true) String hospitalId,
                                   @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
                                   @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
                                   @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
                                   @RequestParam(value = "doctorId", required = true) String doctorId) {
            @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
            @RequestParam(value = "hospitalId", required = true) String hospitalId,
            @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
            @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
            @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
            @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            List<Map<String, Object>> list = guahaoXM.GetDoctorArrangeTenDay(hospitalId, hosDeptId, doctorId);
            return write(200, "获取医生排班成功!", "data", list);
@ -404,54 +452,6 @@ public class BookingController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("取消挂号单")
    public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
                              @RequestParam(value = "orderId", required = true) String 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.updateStatus(obj.getCode(), 0);
                //微信消息
                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());
        }
    }
    /********************************************* 医生端查询 **************************************************************************/
    @RequestMapping(value = "GetPatientReservationList", method = RequestMethod.POST)
    @ResponseBody
@ -460,29 +460,13 @@ public class BookingController extends WeixinBaseController {
                                        @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                        @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "10")
                                        @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                        @ApiParam(name = "patient", value = "患者编号", defaultValue = "10")
                                        @ApiParam(name = "patient", value = "患者编号", defaultValue = "4afdbce6194e412fbc770eb4dfbe7b00")
                                        @RequestParam(value = "patient", required = false) String patient,
                                        @ApiParam(name = "doctor", value = "医生编号", defaultValue = "10")
                                        @ApiParam(name = "doctor", value = "医生编号", defaultValue = "shiliuD20160926005")
                                        @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByPatient(patient, doctor, pageIndex, pageSize);
            //遍历更新预约状态
            for (PatientReservation item : list) {
                String type = item.getType();
                String code = item.getCode();
                if (type.equals("0")) {  //医护网接口
                }
                else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    Integer status = guahaoXM.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
                    //更新状态
                    if (status != null) {
                        patientReservationService.updateStatus(item.getCode(), 0);
                        item.setStatus(status);
                    }
                }
            }
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
@ -497,39 +481,12 @@ public class BookingController extends WeixinBaseController {
                                       @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
                                       @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "10")
                                       @RequestParam(value = "pageSize", required = false) Integer pageSize,
                                       @ApiParam(name = "doctor", value = "医生编号", defaultValue = "10")
                                       @ApiParam(name = "doctor", value = "医生编号", defaultValue = "shiliuD20160926005")
                                       @RequestParam(value = "doctor", required = false) String doctor) {
        try {
            List<PatientReservation> list = patientReservationService.getReservationByDoctor(doctor, pageIndex, pageSize);
            //遍历更新预约状态
            JSONArray array = new JSONArray();
            for (PatientReservation item : list) {
                String type = item.getType();
                String code = item.getCode();
                JSONObject object = new JSONObject();
                Class pClass = (Class) item.getClass();
                for(Field field  : pClass.getDeclaredFields()){
                    field.setAccessible(true);
                    object.put(field.getName(),field.get(item));
                }
                Patient patient = patientService.findByCode(item.getPatient());
                if(patient!=null){
                    object.put("photo",patient.getPhoto());
                }
                array.put(object);
                if (type.equals("0")) {  //医护网接口
            List<Map<String,String>> list = patientReservationService.getReservationByDoctor(doctor, pageIndex, pageSize);
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    Integer status = guahaoXM.GetOrderStatus(item.getOrgCode(), code, item.getSsc());
                    //更新状态
                    if (status != null) {
                        patientReservationService.updateStatus(item.getCode(), 0);
                        item.setStatus(status);
                    }
                }
            }
            return write(200, "获取患者预约信息列表成功!", "data", array);
            return write(200, "获取患者预约信息列表成功!", "data", list);
        } catch (Exception e) {
            return error(-1, e.getMessage());
        }
@ -540,35 +497,13 @@ public class BookingController extends WeixinBaseController {
    @ResponseBody
    @ApiOperation("获取患者预约信息单条-医生端")
    public String GetPatientReservation(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
                                        @RequestParam(value = "orderId", required = true) String orderId) {
                                        @RequestParam(value = "orderId", required = true) Long orderId) {
        try {
            PatientReservation obj = null;
            try {
                obj = patientReservationService.findById(orderId);
            } catch (Exception e) {
                obj = patientReservationService.findByCode(orderId);
            }
            if (obj != null) {
                String type = obj.getType();
                String code = obj.getCode();
                Integer status = null;
                if (type.equals("0")) {  //医护网接口
                } else if (type.equals("1"))   //厦门市民健康预约接口
                {
                    status = guahaoXM.GetOrderStatus(obj.getOrgCode(), code, obj.getSsc());
                }
                //更新状态
                if (status != null) {
                    patientReservationService.updateStatus(obj.getCode(), 0);
                    obj.setStatus(status);
                }
                return write(200, "获取患者预约信息成功!", "data", obj);
            } else {
                return error(-1, "不存在该条预约信息!");
            }
            PatientReservation obj = patientReservationService.findById(orderId);
        } catch (Exception e) {
            return write(200, "获取患者预约信息成功!", "data", obj);
        }
        catch (Exception e) {
            return error(-1, e.getMessage());
        }
    }