Browse Source

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

sand 8 years ago
parent
commit
01e970de45

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/PatientReservation.java

@ -29,6 +29,7 @@ public class PatientReservation extends IdEntity {
	private String doctor;
	// 医生姓名(医生帮患者预约时才会有值)
	private String dname;
	// 患者标识
	private String patient;
	// 患者身份证

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

@ -23,4 +23,7 @@ public interface PatientReservationDao extends PagingAndSortingRepository<Patien
	List<PatientReservation> findByPatient(String patient, Pageable page);
	List<PatientReservation> findByPatientAndDoctor(String patient,String doctor,Pageable page);
	List<PatientReservation> findByDoctor(String doctor,Pageable page);
}

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

@ -7,6 +7,7 @@ import java.util.Map;
import javax.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -150,14 +151,27 @@ public class PatientReservationService extends BaseService {
	}
	/**
	 * 分页获取患者预约记录
	 * 分页获取患者预约记录,医生为空查患者所有
     */
	public List<PatientReservation> getReservationByPatient(String patient, int page, int pagesize) {
	public List<PatientReservation> getReservationByPatient(String patient,String doctor, int page, int pagesize) {
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		return patientReservationDao.findByPatient(patient, pageRequest);
		if(StringUtils.isNotBlank(doctor)){//传入医生查询医生帮此患者的预约记录
			return patientReservationDao.findByPatientAndDoctor(patient, doctor, pageRequest);
		}else{
			return patientReservationDao.findByPatient(patient, pageRequest);
		}
	}
	/**
	 * 分页获取患者预约记录
	 */
	public List<PatientReservation> getReservationByDoctor(String doctor, int page, int pagesize) {
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(page-1, pagesize, sort);
		return patientReservationDao.findByDoctor(doctor, pageRequest);
	}
}

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

@ -17,6 +17,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -35,6 +36,7 @@ public class GuahaoXMService implements IGuahaoService {
    private String ORDER_CREATE = "WebRegisterVerify";  //新建预约
    private String ORDER_CANCEL = "Unregister";   //取消预约
    private String ORDER_INFO = "GetReservationRecord";//预约信息
    private String REG_LIST ="GetRegList";//获取市民预约挂号信息
    @Autowired
    private PatientService patientService;
@ -401,8 +403,9 @@ public class GuahaoXMService implements IGuahaoService {
    /**
     * 创建挂号单
     * update by linz 新增代签约人的code和name用于转诊预约
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception{
        String re = "";
        Patient p = patientService.findByCode(patient);
@ -488,6 +491,12 @@ public class GuahaoXMService implements IGuahaoService {
                reservation.setStartTime(startTime);
                reservation.setEndTime(endTime);
                reservation.setStatus(1);
                if(StringUtils.isNotBlank(dname)){
                    reservation.setDname(dname);//代理签约维护待签约人名称
                }
                if(StringUtils.isNotBlank(dcode)){
                    reservation.setDoctor(dcode);//代理签约维护待签约人编码
                }
                // 保存预约记录
                patientReservationDao.save(reservation);
                re = code;
@ -711,4 +720,216 @@ public class GuahaoXMService implements IGuahaoService {
        }
    }
    /**
     * 根据患者医保卡获取近三个月的预约记录
     */
    public List<PatientReservation> GetRegList(String patientCode,String strStart,String strEnd) throws Exception
    {
        Patient patient = patientService.findByCode(patientCode);
        //获取签名信息
        List<PatientReservation> patientRegList = new ArrayList<>();
        String[] values = SOAPUtil.getCredential(null, true);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
        param1.put("key", "?strSSID");
        param1.put("value", patient.getSsc());
        params.put(param1);
        JSONObject param2 = new JSONObject();
        param2.put("key", "?strStart");
        param2.put("value", strStart);
        params.put(param2);
        JSONObject param3 = new JSONObject();
        param3.put("key", "?strEnd");
        param3.put("value", strEnd);
        params.put(param3);
        JSONObject param4 = new JSONObject();
        param4.put("key", "?strCredential");
        param4.put("value", values[1]);
        params.put(param4);
        JSONObject param5 = new JSONObject();
        param5.put("key", "?strKey");
        param5.put("value",values[2]);  //一周后时间
        params.put(param5);
        String xml = SOAPUtil.post(REG_LIST, params);
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取挂号信息失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
        if(patient==null){
            throw new Exception("获取挂号人员信息失败!");
        }
        for (Object o : child) {
            Element e = (Element) o;
            // 医生编码
            String regdate = e.attributeValue("regdate");//预约日期
            String time = e.attributeValue("time");//a or p 上下午
            String regBegin = e.attributeValue("start_time");//预约时间段的开始时间
            String regEnd = e.attributeValue("end_time");//预约时间段的结束时间
            String orgID = e.attributeValue("orgID");//机构ID
            String OrgCode = e.attributeValue("OrgCode");//医疗机构编码
            String org = e.attributeValue("org");//医疗机构名称
            String DeptCode = e.attributeValue("DeptCode");//科室代码
            String dept =e.attributeValue("dept");//科室
            String DoctorCode = e.attributeValue("DoctorCode");//医生代码
            String doctor = e.attributeValue("doctor");//医生
            String Introduction = e.attributeValue("Introduction");//医生简介
            String status = e.attributeValue("status");//状态:删除、新建、确认、已诊
            String enter_time = e.attributeValue("enter_time");//预约登记时间
            String notes = e.attributeValue("notes");//备注
            String code  = e.getText();//预约号
            PatientReservation patientReservation = new PatientReservation();
            patientReservation.setCode(code);
            patientReservation.setSectionType(time);
            patientReservation.setCzrq(dateFormat.parse(enter_time));
            patientReservation.setDeptCode(DeptCode);
            patientReservation.setDeptName(dept);
            patientReservation.setDoctorCode(DoctorCode);
            patientReservation.setDoctorName(doctor);
            patientReservation.setStartTime(regBegin);
            patientReservation.setEndTime(regEnd);
            patientReservation.setOrgCode(OrgCode);
            patientReservation.setOrgName(org);
            patientReservation.setType("1");
            patientReservation.setPatient(patient.getCode());
            patientReservation.setName(patient.getName());
            patientReservation.setIdcard(patient.getIdcard());
            patientReservation.setPhone(patient.getMobile());
            switch (status){
                case "删除":
                    patientReservation.setStatus(0);
                    break;
                case "新建":
                    patientReservation.setStatus(1);
                    break;
                case "确认":
                    patientReservation.setStatus(2);
                    break;
                case "已诊":
                    patientReservation.setStatus(3);
                    break;
                default:patientReservation.setStatus(4);
            };
            patientReservation.setSsc(patient.getSsc());
            GuahaoDoctor guahaoDoctor = GetDoctorInfo(DoctorCode, OrgCode, DeptCode);
            patientReservation.setDoctorPhoto(guahaoDoctor.getPhoto());//照片
            patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
            patientRegList.add(patientReservation);
        }
        return patientRegList;
    }
    /**
     * 根据患者,预约编号,机构编号获取单条记录预约记录
     */
    public PatientReservation getRegDetail(String patientCode,String orgCode,String regCode) throws Exception
    {
        //获取签名信息
        Patient patient = patientService.findByCode(patientCode);
        StringBuffer sb = new StringBuffer();
        sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        sb.append("<root>");
        sb.append("<org_code>").append(orgCode).append("</org_code>");
        sb.append("<resid>").append(regCode).append("</resid>");
        sb.append("<ssid>").append(patient.getSsc()).append("</ssid>");
        sb.append("</root>");
        String[] values = SOAPUtil.getCredential(sb.toString(), true);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        JSONArray params = new JSONArray();
        JSONObject param1 = new JSONObject();
        param1.put("key", "?strCondition");
        param1.put("value", values[0]);
        params.put(param1);
        JSONObject param2 = new JSONObject();
        param2.put("key", "?strCredential");
        param2.put("value", values[1]);
        params.put(param2);
        JSONObject param3 = new JSONObject();
        param3.put("key", "?strKey");
        param3.put("value", values[2]);
        params.put(param3);
        String xml = SOAPUtil.post(ORDER_INFO, params);
        if (StringUtils.isEmpty(xml)) {
            // 请求失败
            throw new Exception("获取挂号信息失败!");
        } else if (StringUtils.startsWith(xml, "System-Error")) {
            // 调用失败
            throw new Exception(xml.substring(xml.indexOf(":") + 1, xml.length()));
        }
        Document document = DocumentHelper.parseText(xml);
        Element root = document.getRootElement();
        List<?> child = root.elements();
        if(patient==null){
            throw new Exception("获取挂号人员信息失败!");
        }
            Element e = (Element) child.get(0);
            // 医生编码
            String regdate = e.attributeValue("regdate");//预约日期
            String time = e.attributeValue("time");//a or p 上下午
            String regBegin = e.attributeValue("start_time");//预约时间段的开始时间
            String regEnd = e.attributeValue("end_time");//预约时间段的结束时间
            String orgID = e.attributeValue("org_id");//机构ID
            String OrgCode = e.attributeValue("org_code");//医疗机构编码
            String org = e.attributeValue("org_name");//医疗机构名称
            String DeptCode = e.attributeValue("dept_code");//科室代码
            String dept =e.attributeValue("dept_name");//科室
            String DoctorCode = e.attributeValue("doctor_code");//医生代码
            String doctor = e.attributeValue("doctor_name");//医生
            String Introduction = e.attributeValue("introduction");//医生简介
            String status = e.attributeValue("status");//状态:删除、新建、确认、已诊
            String enter_time = e.attributeValue("enter_time");//预约登记时间
            String notes = e.attributeValue("notes");//备注
            String code  = e.getText();//预约号
            PatientReservation patientReservation = new PatientReservation();
            patientReservation.setCode(code);
            patientReservation.setSectionType(time);
            patientReservation.setCzrq(dateFormat.parse(enter_time));
            patientReservation.setDeptCode(DeptCode);
            patientReservation.setDeptName(dept);
            patientReservation.setDoctorCode(DoctorCode);
            patientReservation.setDoctorName(doctor);
            patientReservation.setStartTime(regBegin);
            patientReservation.setEndTime(regEnd);
            patientReservation.setOrgCode(OrgCode);
            patientReservation.setOrgName(org);
            patientReservation.setType("1");
            patientReservation.setPatient(patient.getCode());
            patientReservation.setName(patient.getName());
            patientReservation.setIdcard(patient.getIdcard());
            patientReservation.setPhone(patient.getMobile());
            switch (status){
                case "删除":
                    patientReservation.setStatus(0);
                    break;
                case "新建":
                    patientReservation.setStatus(1);
                    break;
                case "确认":
                    patientReservation.setStatus(2);
                    break;
                case "已诊":
                    patientReservation.setStatus(3);
                    break;
                default:patientReservation.setStatus(4);
            };
            patientReservation.setSsc(patient.getSsc());
            GuahaoDoctor guahaoDoctor = GetDoctorInfo(DoctorCode, OrgCode, DeptCode);
            patientReservation.setDoctorPhoto(guahaoDoctor.getPhoto());//照片
            patientReservation.setDoctorJob(guahaoDoctor.getTitle());//职称
            return patientReservation;
    }
}

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

@ -227,7 +227,7 @@ public class GuahaoYihuService implements IGuahaoService {
    /**
     * 创建挂号单
     */
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception{
    public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode) throws Exception{
        return  "";
    }

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

@ -2,6 +2,8 @@
package com.yihu.wlyy.service.third.guahao;
import com.yihu.wlyy.entity.patient.PatientReservation;
import java.util.List;
import java.util.Map;
@ -36,7 +38,7 @@ public interface IGuahaoService{
	/**
	 * 创建挂号单
	 */
	public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone) throws Exception;
	public String CreateOrder(String hospitalId,String hospitalName,String hosDeptId,String hosDeptName,String doctorId,String doctorName,String arrangeDate,String patient,String patientName,String cardNo,String clinicCard,String patientPhone,String dname,String dcode ) throws Exception;
	/**
	 * 获取医生信息

+ 114 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/WlyySerivceController.java

@ -1,11 +1,20 @@
package com.yihu.wlyy.web.common.util;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.SOAPUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.parser.JSONParser;
import net.sf.json.JSON;
import net.sf.json.util.JSONUtils;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -13,6 +22,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by lyr on 2016/9/29.
 */
@ -179,4 +191,106 @@ public class WlyySerivceController extends BaseController{
        }
    }
    /**
     * 转诊预约医生特殊号源获取
     * @param OrgCode 医院编号
     * @param DeptCode 科室编号
     * @param DocCode 医生编号
     * @return
     */
    @RequestMapping(value = "/third/smjk/RegDeptSpeDoctorSectionList",method = RequestMethod.POST)
    @ApiOperation("转诊预约获取特殊号源接口")
    public String getSpeDoctorSectionList(@RequestParam("OrgCode") String OrgCode,@RequestParam("DeptCode") String DeptCode,@RequestParam("DocCode") String DocCode){
        try{
            SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
            Date nowDate =new Date();
            Date tenDateAfter =  getDateAfter(nowDate,10);
            String strStart = sm.format(nowDate);
            String strEnd = sm.format(tenDateAfter);
            String checkUrl = SystemConf.getInstance().getSystemProperties().getProperty("sign_check_upload");
            String param = "?OrgCode="+OrgCode+"&DeptCode="+DeptCode+"&strStart="+strStart+"&strEnd="+strEnd+"&DocCode="+DocCode;
            String jsonString = HttpUtil.sendPost(checkUrl + "/third/smjk/RegDeptSpeDoctorSectionList"+param,"" );
            if(StringUtils.isEmpty(jsonString)){
                return write(-1,"医生排班时间获取失败");
            }else{
                JSONObject myJsonObject = new JSONObject(jsonString);
                return write(200,"医生排班时间获取成功","data",parseXmlForSpe(myJsonObject.get("data").toString()));
            }
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"医生排班时间获取失败");
        }
    }
    /**
     * 转诊预约医生号源转换
     * @param xml
     * @return
     */
    private List<Map<String,Object>>  parseXmlForSpe(String xml) {
            List<Map<String,Object>> re = new ArrayList<>();
            Document document = null;
            try{
                 document = DocumentHelper.parseText(xml);
             }catch (Exception e){
                throw new RuntimeException("解析数据失败!");
            }
            Element root = document.getRootElement();
            List<?> child = root.elements();//取出root的子集合
            for (Object o : child) {
                List<?> dataList = ((Element) o).elements();
                for(Object dataElement:dataList) {
                    Element e = (Element) dataElement;
                    // 日期
                    String date = e.attributeValue("date");
                    // a或者p
                    String time = e.attributeValue("time");
                    // 限号
                    String max = e.attributeValue("max");
                    // 已使用的号
                    String used = e.attributeValue("used");
                    // 1正常、2满号、3已过期
                    String status = e.attributeValue("status");
                    Map<String, Object> map = new HashMap<>();
                    map.put("date", date);
                    map.put("time", time);
                    map.put("max", max);
                    map.put("used", used);
                    map.put("status", status);
                    // 排班信息
                    List<?> sections = e.elements();
                    List<Map<String, String>> arrangeList = new ArrayList<>();
                    for (Object s : sections) {
                        Element section = (Element) s;
                        // 限号
                        String s_max = section.attributeValue("max");
                        // 已使用的号
                        String s_used = section.attributeValue("used");
                        // 一次专家坐诊时间段的开始时间
                        String start_time = section.attributeValue("start_time");
                        // 结束时间
                        String end_time = section.attributeValue("end_time");
                        Map<String, String> item = new HashMap<>();
                        item.put("max", s_max);
                        item.put("used", s_used);
                        item.put("startTime", start_time);
                        item.put("endTime", end_time);
                        arrangeList.add(item);
                    }
                    map.put("sections", arrangeList);
                    re.add(map);
                }
            }
            return  re;
        }
        public static Date getDateAfter(Date d, int day) {
            Calendar now = Calendar.getInstance();
            now.setTime(d);
            now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
            return now.getTime();
      }
}

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

@ -0,0 +1,61 @@
package com.yihu.wlyy.web.doctor.patient;
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;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.DoctorPatientGroupService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 医生端:患者分组管理
 *
 * @author George
 */
@Controller
@RequestMapping(value = "/doctor/patient", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-患者信息")
public class PatientInfoController extends BaseController {
    @Autowired
    private PatientInfoService patientInfoService;
    /**
     * 获取患者基本信息
     *
     * @return
     */
    @RequestMapping(value = "info")
    @ResponseBody
    public String getPatient(String patient) {
        try {
            // 获取医生下的患者
            Patient temp = patientInfoService.findByCode(patient);
            return write(200, "获取患者信息成功!", "data", temp);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取患者信息失败!");
        }
    }
}

+ 165 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/BookingController.java

@ -23,6 +23,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -250,7 +253,7 @@ public class BookingController extends WeixinBaseController {
			if (StringUtils.isEmpty(patientPhone)) {
				return error(-1, "未设置手机号码!");
			}
			String orderCode =  getService(city).CreateOrder(hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,arrangeDate,patient,patientName,cardNo,clinicCard,patientPhone);
			String orderCode =  getService(city).CreateOrder(hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,arrangeDate,patient,patientName,cardNo,clinicCard,patientPhone,null,null);
			//预约发送微信消息
			PatientReservation obj = patientReservationService.findByCode(orderCode);
@ -281,6 +284,74 @@ public class BookingController extends WeixinBaseController {
		}
	}
	/**
	 * 创建挂号单
	 */
	@RequestMapping(value = "CreateOrderByDoctor",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("创建挂号单")
	public String CreateOrderByDoctor(@ApiParam(name="city",value="城市编码",defaultValue = "350200")
							  @RequestParam(value="city",required = true) String city,
							  @ApiParam(name="hospitalId",value="医院ID",defaultValue = "350211A1001")
							  @RequestParam(value="hospitalId",required = true) String hospitalId,
							  @ApiParam(name="hospitalName",value="医院名称",defaultValue = "厦门大学附属第一医院")
							  @RequestParam(value="hospitalName",required = true) String hospitalName,
							  @ApiParam(name="hosDeptId",value="科室ID",defaultValue = "1040610")
							  @RequestParam(value="hosDeptId",required = true) String hosDeptId,
							  @ApiParam(name="hosDeptName",value="医院科室名称",defaultValue = "儿二科")
							  @RequestParam(value="hosDeptName",required = true) String hosDeptName,
							  @ApiParam(name="doctorId",value="医生ID",defaultValue = "07101")
							  @RequestParam(value="doctorId",required = true) String doctorId,
							  @ApiParam(name="doctorName",value="医生姓名",defaultValue = "林素莲")
							  @RequestParam(value="doctorName",required = true) String doctorName,
							  @ApiParam(name="arrangeDate",value="排班信息",defaultValue = "{\"sectionType\":\"a\",\"startTime\":\"2016-09-02 08:20:00\",\"endTime\":\"2016-09-02 08:30:00\"}")
							  @RequestParam(value="arrangeDate",required = true) String arrangeDate,
							  @ApiParam(name="patient",value="患者代码",defaultValue = "01954b2ebbb24a40a05da9d2f5c94795")
							  @RequestParam(value="patient",required = true) String patient,
							  @ApiParam(name="patientName",value="患者姓名",defaultValue = "张锦川")
							  @RequestParam(value="patientName",required = true) String patientName,
							  @ApiParam(name="cardNo",value="身份证号码",defaultValue = "35052419880511553X")
							  @RequestParam(value="cardNo",required = true) String cardNo,
							  @ApiParam(name="clinicCard",value="市民卡号",defaultValue = "D57117706")
							  @RequestParam(value="clinicCard",required = true) String clinicCard,
							  @ApiParam(name="patientPhone",value="患者手机",defaultValue = "13950116510")
							  @RequestParam(value="patientPhone",required = true) String patientPhone,
                              @ApiParam(name="dcode",value="代预约医生编号",defaultValue = "test00000000005")
							  @RequestParam(value="dcode",required = true) String dcode,
							  @ApiParam(name="dname",value="代预约医生名称",defaultValue = "组2全科医生")
					 		  @RequestParam(value="dname",required = true) String dname) {
		try {
			if (StringUtils.isEmpty(patientName)) {
				return error(-1, "未设置姓名!");
			}
			if (StringUtils.isEmpty(cardNo)) {
				return error(-1, "未设置身份证号!");
			}
			if (StringUtils.isEmpty(clinicCard)) {
				return error(-1, "未设置社保卡号!");
			}
			if (StringUtils.isEmpty(patientPhone)) {
				return error(-1, "未设置手机号码!");
			}
			String orderCode =  getService(city).CreateOrder(hospitalId,hospitalName,hosDeptId,hosDeptName,doctorId,doctorName,arrangeDate,patient,patientName,cardNo,clinicCard,patientPhone,dname,dcode);
			//获取预约信息查询是否挂号成功
			PatientReservation obj = patientReservationService.findByCode(orderCode);
			if(obj!=null)
			{
				return write(200, "创建挂号单成功!");
			}
			else{
				return error(-1,"创建挂号单失败!");
			}
		}
		catch (Exception e) {
			return error(-1,e.getMessage());
		}
	}
	/**
	 * 取消挂号单
	 */
@ -338,14 +409,55 @@ public class BookingController extends WeixinBaseController {
	 */
	@RequestMapping(value = "GetPatientReservationList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息列表接口")
	@ApiOperation("获取患者预约信息列表接口-医生端")
	public String GetPatientReservation(@ApiParam(name="pageIndex",value="第几页",defaultValue = "1")
										@RequestParam(value="pageIndex",required = false) Integer pageIndex,
										@ApiParam(name="pageSize",value="每页记录数",defaultValue = "10")
										@RequestParam(value="pageSize",required = false) Integer pageSize) {
										@RequestParam(value="pageSize",required = false) Integer pageSize,
										@ApiParam(name="patient",value="患者编号",defaultValue = "10")
										@RequestParam(value="patient",required = false) String patient,
										@ApiParam(name="doctor",value="医生编号",defaultValue = "10")
										@RequestParam(value="doctor",required = false) String doctor) {
		try {
			List<PatientReservation> list =  patientReservationService.getReservationByPatient(getUID(),pageIndex,pageSize);
			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());
		}
	}
	/**
	 * 获取医生代预约信息列表接口
	 */
	@RequestMapping(value = "GetDoctorReservationList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取医生代预约信息列表接口-医生端")
	public String GetDoctorReservation(@ApiParam(name="pageIndex",value="第几页",defaultValue = "1")
										@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")
										@RequestParam(value="doctor",required = false) String doctor) {
		try {
			List<PatientReservation> list =  patientReservationService.getReservationByDoctor(doctor,pageIndex,pageSize);
			//遍历更新预约状态
			for(PatientReservation item :list)
			{
@ -370,14 +482,41 @@ public class BookingController extends WeixinBaseController {
		}
	}
	/**
	 * 获取患者预约信息列表接口
	 */
	@RequestMapping(value = "GetRegList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息列表接口--患者端")
	public String GetRegList(@ApiParam(name="patient",value="患者编号",defaultValue = "1")
										@RequestParam(value="patient",required = false) String patient) {
		try {
			SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
			Date nowDate = new Date();
			Date threeMonthBefore = getMonthBefore(nowDate, 3);
			List<PatientReservation> list  = guahaoXM.GetRegList(patient,sm.format(threeMonthBefore),sm.format(nowDate));
			return write(200, "获取患者预约信息列表成功!", "data", list);
		} catch (Exception e) {
			return error(-1,e.getMessage());
		}
	}
	public static Date getMonthBefore(Date d, int month) {
		Calendar now = Calendar.getInstance();
		now.setTime(d);
		now.set(Calendar.MONTH, now.get(Calendar.MONTH) - month);
		return now.getTime();
	}
	/**
	 * 获取患者预约信息单条
	 */
	@RequestMapping(value = "GetPatientReservation",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息单条")
	@ApiOperation("获取患者预约信息单条-医生端")
	public String GetPatientReservation(@ApiParam(name="orderId",value="订单id",defaultValue = "9")
											@RequestParam(value="orderId",required = true) String orderId) {
										 @RequestParam(value="orderId",required = true) String orderId) {
		try {
			PatientReservation obj =  patientReservationService.findById(orderId);
			if(obj!=null) {
@ -406,4 +545,24 @@ public class BookingController extends WeixinBaseController {
			return error(-1,e.getMessage());
		}
	}
	/**
	 * 获取患者预约信息单条
	 */
	@RequestMapping(value = "GetPatientReservationXm",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息单条-患者端")
	public String GetPatientReservationXm(@ApiParam(name="patientCode",value="患者编号")
										@RequestParam(value="patientCode",required = true) String patientCode,
										@ApiParam(name="orgCode",value="机构编码")
										@RequestParam(value="orgCode",required = true) String orgCode,
										@ApiParam(name="regCode",value="挂号单号")
										@RequestParam(value="regCode",required = true) String regCode) {
		try {
			PatientReservation obj =  guahaoXM.getRegDetail(patientCode,orgCode,regCode);
			return write(200, "获取患者预约信息成功!", "data", obj);
		} catch (Exception e) {
			return error(-1,e.getMessage());
		}
	}
}