Browse Source

新增医生端获取病人信息接口,及转诊预约号源开发

8 years ago
parent
commit
b9eade5448

+ 113 - 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,107 @@ public class GuahaoXMService implements IGuahaoService {
        }
    }
    /**
     * 获取医生信息
     */
    public List<PatientReservation> GetRegList(String strSSID,String strStart,String strEnd) throws Exception
    {
        //获取签名信息
        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", strSSID);
        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();
        Patient patient = patientService.findBySsc(strSSID);
        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(strSSID);
            patientRegList.add(patientReservation);
        }
        return patientRegList;
    }
}

+ 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;
	/**
	 * 获取医生信息

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

@ -195,8 +195,6 @@ public class WlyySerivceController extends BaseController{
     * 转诊预约医生特殊号源获取
     * @param OrgCode 医院编号
     * @param DeptCode 科室编号
     * @param strStart 开始时间
     * @param strEnd 结束时间
     * @param DocCode 医生编号
     * @return
     */

+ 98 - 2
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());
		}
	}
	/**
	 * 取消挂号单
	 */
@ -345,7 +416,6 @@ public class BookingController extends WeixinBaseController {
										@RequestParam(value="pageSize",required = false) Integer pageSize) {
		try {
			List<PatientReservation> list =  patientReservationService.getReservationByPatient(getUID(),pageIndex,pageSize);
			//遍历更新预约状态
			for(PatientReservation item :list)
			{
@ -370,6 +440,32 @@ public class BookingController extends WeixinBaseController {
		}
	}
	/**
	 * 获取患者预约信息列表接口
	 */
	@RequestMapping(value = "GetRegList",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("获取患者预约信息列表接口")
	public String GetRegList(@ApiParam(name="strSSID",value="市民卡号",defaultValue = "1")
										@RequestParam(value="strSSID",required = false) String strSSID) {
		try {
			SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
			Date nowDate = new Date();
			Date threeMonthBefore = getMonthBefore(nowDate, 3);
			List<PatientReservation> list  = guahaoXM.GetRegList(strSSID,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();
	}
	/**
	 * 获取患者预约信息单条
	 */