Browse Source

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

trick9191 7 years ago
parent
commit
70f4eaf615
16 changed files with 375 additions and 99 deletions
  1. 85 0
      common/common-entity/src/main/java/com/yihu/mm/entity/patient/ExamReport.java
  2. 11 0
      common/common-entity/src/main/java/com/yihu/mm/entity/patient/PatientExam.java
  3. 9 0
      common/common-entity/src/main/java/com/yihu/mm/entity/questionnaire/MedicineAnswerLog.java
  4. 0 22
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/BaseController.java
  5. 88 41
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  6. 17 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/exam/MedicineAnswerLogDao.java
  7. 2 2
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/patient/PatientExamDao.java
  8. 36 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/MedicineAnswerLogService.java
  9. 15 12
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java
  10. 46 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/JSONUtil.java
  11. 12 9
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java
  12. 7 6
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/entity/WlyyMedicineKey.java
  13. 7 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/repository/WlyyMedicineKeyDao.java
  14. 4 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java
  15. 32 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/medicine/WlyyMedicineKeyService.java
  16. 4 4
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java

+ 85 - 0
common/common-entity/src/main/java/com/yihu/mm/entity/patient/ExamReport.java

@ -0,0 +1,85 @@
package com.yihu.mm.entity.patient;
import com.yihu.mm.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name = "exam_report")
public class ExamReport extends IdEntity implements Serializable {
    @Column(name="patient")
    private String patient;//居民code
    @Column(name="cc_id")
    private String ccId;//咨询结论编号
    @Column(name="ct_id")
    private String ctId;//咨询编号
    @Column(name="cl_id")
    private String clId;//结论编号
    @Column(name="cc_last")
    private String ccLast;//最终结论
    @Column(name="cl_template")
    private String clTemplate;//显示模板
    @Column(name="cl_sort")
    private String clSort;//结论排序权重
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getCcId() {
        return ccId;
    }
    public void setCcId(String ccId) {
        this.ccId = ccId;
    }
    public String getCtId() {
        return ctId;
    }
    public void setCtId(String ctId) {
        this.ctId = ctId;
    }
    public String getClId() {
        return clId;
    }
    public void setClId(String clId) {
        this.clId = clId;
    }
    public String getCcLast() {
        return ccLast;
    }
    public void setCcLast(String ccLast) {
        this.ccLast = ccLast;
    }
    public String getClTemplate() {
        return clTemplate;
    }
    public void setClTemplate(String clTemplate) {
        this.clTemplate = clTemplate;
    }
    public String getClSort() {
        return clSort;
    }
    public void setClSort(String clSort) {
        this.clSort = clSort;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/mm/entity/patient/PatientExam.java

@ -18,6 +18,9 @@ public class PatientExam extends IdEntity implements Serializable {
    @Column(name="tp_id")
    @Column(name="tp_id")
    private String tpId;
    private String tpId;
    @Column(name="tp_name")
    private String tpName;
    @Column(name="ct_id")
    @Column(name="ct_id")
    private String ctId;
    private String ctId;
@ -55,4 +58,12 @@ public class PatientExam extends IdEntity implements Serializable {
    public void setIsComplete(Integer isComplete) {
    public void setIsComplete(Integer isComplete) {
        this.isComplete = isComplete;
        this.isComplete = isComplete;
    }
    }
    public String getTpName() {
        return tpName;
    }
    public void setTpName(String tpName) {
        this.tpName = tpName;
    }
}
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/mm/entity/questionnaire/MedicineAnswerLog.java

@ -18,6 +18,7 @@ public class MedicineAnswerLog extends IdEntity {
    private String tpId;    //试卷编号
    private String tpId;    //试卷编号
    private String tpName; //试卷名称
    private String tpName; //试卷名称
    private String pbType;  //问卷类型
    private String pbType;  //问卷类型
    private String pbId;//试题编号
    private Date createTime;    //创建时间
    private Date createTime;    //创建时间
    private String problems;    //问题的集合
    private String problems;    //问题的集合
@ -69,4 +70,12 @@ public class MedicineAnswerLog extends IdEntity {
    public void setPbType(String pbType) {
    public void setPbType(String pbType) {
        this.pbType = pbType;
        this.pbType = pbType;
    }
    }
    public String getPbId() {
        return pbId;
    }
    public void setPbId(String pbId) {
        this.pbId = pbId;
    }
}
}

+ 0 - 22
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/BaseController.java

@ -1,7 +1,6 @@
package com.yihu.mm.controller;
package com.yihu.mm.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.IdEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
@ -389,27 +388,6 @@ public class BaseController {
		}
		}
	}
	}
	/**
	* 返回接口处理结果
	*
	*
	* @param code 结果码,成功为200
	* @param msg 结果提示信息
	* @return
	*/
	public String write(int code, String msg, String key, IdEntity entity) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, entity);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	/**
	 * 返回接口处理结果
	 * 返回接口处理结果

+ 88 - 41
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java

@ -2,10 +2,13 @@ package com.yihu.mm.controller.medicine;
import com.yihu.mm.controller.BaseController;
import com.yihu.mm.controller.BaseController;
import com.yihu.mm.entity.patient.PatientExam;
import com.yihu.mm.entity.patient.PatientExam;
import com.yihu.mm.entity.questionnaire.MedicineAnswerLog;
import com.yihu.mm.service.MedicineAnswerLogService;
import com.yihu.mm.service.PatientExamService;
import com.yihu.mm.service.PatientExamService;
import com.yihu.mm.service.PatientService;
import com.yihu.mm.service.PatientService;
import com.yihu.mm.service.PhysicalExaminationService;
import com.yihu.mm.service.PhysicalExaminationService;
import com.yihu.mm.util.HttpClientUtil;
import com.yihu.mm.util.HttpClientUtil;
import com.yihu.wlyy.entity.patient.Patient;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;
@RestController
@RestController
@RequestMapping(value = "/medicine/physicalExamination")
@RequestMapping(value = "/medicine/physicalExamination")
@ -35,6 +40,8 @@ public class PhysicalExaminationController extends BaseController {
    @Autowired
    @Autowired
    private PhysicalExaminationService physicalExaminationService;
    private PhysicalExaminationService physicalExaminationService;
    @Autowired
    private MedicineAnswerLogService medicineAnswerLogService;
    @Autowired
    @Autowired
    private PatientExamService patientExamService;
    private PatientExamService patientExamService;
@ -47,22 +54,33 @@ public class PhysicalExaminationController extends BaseController {
                             HttpServletRequest req
                             HttpServletRequest req
                             ) {
                             ) {
        HttpSession session = req.getSession();
        HttpSession session = req.getSession();
        String key = (String) session.getAttribute("key");
        if(StringUtils.isBlank(key)){
            //通过接口查询key
            String result = HttpClientUtil.postBody(yuerenApi + "/phonekey", new JSONObject());
            JSONObject jsonObject = new JSONObject(result);
            String status = jsonObject.get("status").toString();
            if ("200".equals(status)) {
                JSONObject recordset = jsonObject.getJSONObject("recordset");
                key = recordset.getString("key");
            }else{
                return result;
            }
            session.setMaxInactiveInterval(60*60*4);
            session.setAttribute("key",key);
            String key = (String) session.getAttribute("key");
            if(StringUtils.isBlank(key)){
                //通过接口查询key
                String result = HttpClientUtil.postBody(yuerenApi + "/phonekey", new JSONObject());
                JSONObject jsonObject = new JSONObject(result);
                String status = jsonObject.get("status").toString();
                if ("200".equals(status)) {
                    JSONObject recordset = jsonObject.getJSONObject("recordset");
                    key = recordset.getString("key");
                }else{
                    return result;
                }
                session.setMaxInactiveInterval(60*60*4);
                session.setAttribute("key",key);
        }
        }
        return physicalExaminationService.findExames(key,tp_type, examCode);
        String exames = physicalExaminationService.findExames(tp_type, examCode);
        //if(StringUtils.isNotBlank(examCode)){
        //    JSONObject examJson = new JSONObject(exames);
        //    String exam_status = examJson.get("status").toString();
        //    if ("200".equals(exam_status)) {
        //        JSONObject recordset = examJson.getJSONObject("recordset");
        //        key = recordset.getString("key");
        //    }else{
        //        return result;
        //    }
        //}
        return exames;
    }
    }
    @ApiOperation(value = "新增预约单/获取咨询编号等信息")
    @ApiOperation(value = "新增预约单/获取咨询编号等信息")
@ -70,9 +88,8 @@ public class PhysicalExaminationController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode, HttpServletRequest req){
    public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode, HttpServletRequest req){
        String key = (String) req.getSession().getAttribute("key");
        String key = (String) req.getSession().getAttribute("key");
        //Patient patient = patientService.findByCode(patientCode);
        //return physicalExaminationService.insertslip(key,patient);
        return null;
        Patient patient = patientService.findByCode(patientCode);
        return physicalExaminationService.insertslip(patient);
    }
    }
@ -82,31 +99,42 @@ public class PhysicalExaminationController extends BaseController {
    public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
    public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                               @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                               HttpServletRequest req){
        HttpSession session = req.getSession();
        String key = (String) session.getAttribute("key");
                               HttpServletRequest req) throws IOException {
        String ct_id="";
        String ct_id="";
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        if(patientExam==null){
        if(patientExam==null){
            //Patient patient = patientService.findByCode(patientCode);
            //String result = physicalExaminationService.insertslip(key, patient);
            //JSONObject jsonObject = new JSONObject(result);
            //String status = jsonObject.get("status").toString();
            //if ("200".equals(status)) {
            //    JSONObject recordset = jsonObject.getJSONObject("recordset");
            //    ct_id = recordset.getString("ct_id");
            //    patientExam = new PatientExam();
            //    patientExam.setCtId(ct_id);
            //    patientExam.setPatient(patientCode);
            //    patientExam.setIsComplete(0);
            //    patientExam.setTpId(tp_id);
            //    patientExamService.save(patientExam);
            //}else{
            //    return result;
            //}
            Patient patient = patientService.findByCode(patientCode);
            String result = physicalExaminationService.insertslip(patient);
            JSONObject jsonObject = new JSONObject(result);
            String status = jsonObject.get("status").toString();
            if ("200".equals(status)) {
                JSONObject recordset = jsonObject.getJSONObject("recordset");
                ct_id = recordset.get("ct_id").toString();
                patientExam = new PatientExam();
                patientExam.setCtId(ct_id);
                patientExam.setPatient(patientCode);
                patientExam.setIsComplete(0);
                patientExam.setTpId(tp_id);
                patientExamService.save(patientExam);
            }else{
                return result;
            }
        }else{
            ct_id = patientExam.getCtId();
        }
        String question = physicalExaminationService.findQuestion(tp_id, pb_id, ct_id);
        JSONObject jsonQuestion = new JSONObject(question);
        jsonQuestion.put("answer","");
        //查找居民是否已经答过该试题
        MedicineAnswerLog answer = medicineAnswerLogService.findAnswer(patientCode, tp_id, pb_id);
        if(answer!=null){
            jsonQuestion.put("answer",answer);
        }
        }
        String question = physicalExaminationService.findQuestion(key, tp_id, pb_id, ct_id);
        //Map<String, Object> resp = customerService.findServerInfo(patient);
        //resp.put("patient",patient);
        //return write(1,"查询成功","data",resp);
        return question;
        return question;
    }
    }
@ -115,14 +143,30 @@ public class PhysicalExaminationController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String handleExam(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
    public String handleExam(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                                @ApiParam(name = "i_multiselect", value = "试题类型(0单选 ,1多选)", required = true)@RequestParam(required = true, name = "i_multiselect") String i_multiselect,
                               @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                               @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                             @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                             @ApiParam(name = "isLast", value = "是否是最后一题(0否 ,1是)", required = true)@RequestParam(required = true, name = "isLast") String isLast,
                            HttpServletRequest req){
                            HttpServletRequest req){
        String key = (String) req.getSession().getAttribute("key");
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        String tpName = patientExam.getTpName();
        String ct_id = patientExam.getCtId();
        String ct_id = patientExam.getCtId();
        String result = physicalExaminationService.handleExam(key, tp_id, pb_id, dc_answer, ct_id);
        String result = physicalExaminationService.handleExam(tp_id, pb_id, dc_answer, ct_id);
        //将答案保存到自己数据库
        MedicineAnswerLog medicineAnswerLog = new MedicineAnswerLog();
        medicineAnswerLog.setPatientCode(patientCode);
        medicineAnswerLog.setTpId(tp_id);
        medicineAnswerLog.setTpName(tpName);
        medicineAnswerLog.setPbType(String.valueOf(i_multiselect));
        medicineAnswerLog.setCreateTime(new Date());
        medicineAnswerLog.setProblems(dc_answer);
        medicineAnswerLogService.save(medicineAnswerLog);
        //最后一题
        if("1".equals(isLast)){
        }
        return result;
        return result;
    }
    }
@ -142,6 +186,9 @@ public class PhysicalExaminationController extends BaseController {
    @RequestMapping(value = "/findconconhealth",produces="application/json;charset=UTF-8")
    @RequestMapping(value = "/findconconhealth",produces="application/json;charset=UTF-8")
    @ResponseBody
    @ResponseBody
    public String findconconhealth(@ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
    public String findconconhealth(@ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        String result = physicalExaminationService.findconconhealth(ct_id);
        return null;
        return null;
    }
    }

+ 17 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/exam/MedicineAnswerLogDao.java

@ -0,0 +1,17 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.repository.mm.exam;
import com.yihu.mm.entity.questionnaire.MedicineAnswerLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface MedicineAnswerLogDao extends PagingAndSortingRepository<MedicineAnswerLog, String>,JpaSpecificationExecutor<MedicineAnswerLog> {
	@Query("select m from MedicineAnswerLog m where m.patientCode=?1 and m.tpId=?2 and m.pbId=?3")
    MedicineAnswerLog findAnswer(String patientCode, String tp_id, String pb_id);
}

+ 2 - 2
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/patient/PatientExamDao.java

@ -13,7 +13,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface PatientExamDao extends PagingAndSortingRepository<PatientExam, String>,JpaSpecificationExecutor<PatientExam> {
public interface PatientExamDao extends PagingAndSortingRepository<PatientExam, String>,JpaSpecificationExecutor<PatientExam> {
	// 查询患者code和试卷编号查询
	// 查询患者code和试卷编号查询
	@Query("select p from PatientExam p where p.id=?1 and p.tpId=?2")
	PatientExam findByPatientAndTpId(String id, String tpId);
	@Query("select p from PatientExam p where p.patient=?1 and p.tpId=?2")
	PatientExam findByPatientAndTpId(String patientCode, String tpId);
}
}

+ 36 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/MedicineAnswerLogService.java

@ -0,0 +1,36 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.service;
import com.yihu.mm.entity.questionnaire.MedicineAnswerLog;
import com.yihu.mm.repository.mm.exam.MedicineAnswerLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.persistence.Transient;
/**
 * 患者基本信息类.
 *
 * @author George
 */
@Service
public class MedicineAnswerLogService {
    @Autowired
    private MedicineAnswerLogDao medicineAnswerLogDao;
    @Transient
    public void save(MedicineAnswerLog medicineAnswerLog){
        medicineAnswerLogDao.save(medicineAnswerLog);
    }
    public MedicineAnswerLog findAnswer(String patientCode,String tp_id,String pb_id){
        return  medicineAnswerLogDao.findAnswer(patientCode,tp_id,pb_id);
    }
}

+ 15 - 12
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java

@ -15,21 +15,19 @@ public class PhysicalExaminationService {
    @Value(("${yuerenApi}"))
    @Value(("${yuerenApi}"))
    private String yuerenApi;
    private String yuerenApi;
    public String findExames(String key,String type, String examCode) {
    public String findExames(String type, String examCode) {
        //先获取key值
        //先获取key值
        JSONObject params = new JSONObject();
        JSONObject params = new JSONObject();
        params.put("key",key);
        params.put("tp_type", type);
        params.put("tp_type", type);
        params.put("sh_id", examCode);
        params.put("sh_id", examCode);
        return HttpClientUtil.postBody(yuerenApi + "/findtest", params);
        return HttpClientUtil.postBody(yuerenApi + "/findtest", params);
    }
    }
    public String insertslip(String key,Patient patient) {
    public String insertslip(Patient patient) {
        Date date = new Date();
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONObject params = new JSONObject();
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("sl_date", sdf.format(date));
        params.put("sl_date", sdf.format(date));
        params.put("sl_state", "未签到");
        params.put("sl_state", "未签到");
        params.put("u_tel", patient.getMobile());
        params.put("u_tel", patient.getMobile());
@ -44,7 +42,7 @@ public class PhysicalExaminationService {
        params.put("u_sex",sexStr );
        params.put("u_sex",sexStr );
        //todo    sh_id 需要从数据库获取   wlyy_medicine_strores_no
        //todo    sh_id 需要从数据库获取   wlyy_medicine_strores_no
        params.put("sh_id", "");
        params.put("sh_id", "52");
        params.put("u_idnum", patient.getIdcard());
        params.put("u_idnum", patient.getIdcard());
        //params.put("u_native", u_native);//籍贯
        //params.put("u_native", u_native);//籍贯
        params.put("u_birthday", patient.getBirthday());
        params.put("u_birthday", patient.getBirthday());
@ -53,27 +51,32 @@ public class PhysicalExaminationService {
        params.put("u_area", patient.getTownName());
        params.put("u_area", patient.getTownName());
        params.put("u_address", patient.getAddress());
        params.put("u_address", patient.getAddress());
        //params.put("sl_pass", );//报告单是否审核通过
        //params.put("sl_pass", );//报告单是否审核通过
        return HttpClientUtil.postBody(yuerenApi + "/findtest", params);
        return HttpClientUtil.postBody(yuerenApi + "/insertslip", params);
    }
    }
    public String findQuestion(String key, String tp_id, String pb_id, String ct_id) {
    public String findQuestion(String tp_id, String pb_id, String ct_id) {
        JSONObject params = new JSONObject();
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
        params.put("ct_id", ct_id);
        params.put("tp_id", tp_id);
        params.put("tp_id", tp_id);
        params.put("pb_id", pb_id);
        params.put("pb_id", pb_id);
        String postStr = HttpClientUtil.postBody("/yueren/giveproblem", params);
        String postStr = HttpClientUtil.postBody(yuerenApi+"/giveproblem", params);
        return postStr;
        return postStr;
    }
    }
    public String handleExam(String key, String tp_id, String pb_id, String dc_answer, String ct_id) {
    public String handleExam(String tp_id, String pb_id, String dc_answer, String ct_id) {
        JSONObject params = new JSONObject();
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
        params.put("ct_id", ct_id);
        params.put("tp_id", tp_id);
        params.put("tp_id", tp_id);
        params.put("pb_id", pb_id);
        params.put("pb_id", pb_id);
        params.put("dc_answer", dc_answer);
        params.put("dc_answer", dc_answer);
        return HttpClientUtil.postBody("/yueren/handleproblem", params);
        return HttpClientUtil.postBody(yuerenApi+"/handleproblem", params);
    }
    public String findconconhealth(String ct_id) {
        JSONObject params = new JSONObject();
        params.put("ct_id", ct_id);
        params.put("reqtype", 1);
        return HttpClientUtil.postBody(yuerenApi+"/findconconhealth", params);
    }
    }
}
}

+ 46 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/JSONUtil.java

@ -0,0 +1,46 @@
package com.yihu.mm.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
public class JSONUtil {
    /**
     * 将json转化为实体POJO
     * @param jsonStr
     * @param obj
     * @return
     */
    public static<T> Object JSONToObj(String jsonStr,Class<T> obj) {
        T t = null;
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            t = objectMapper.readValue(jsonStr,
                    obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return t;
    }
    /**
     * 将实体POJO转化为JSON
     * @param obj
     * @return
     * @throws JSONException
     * @throws IOException
     */
    public static<T> JSONObject objectToJson(T obj) throws JSONException, IOException {
        ObjectMapper mapper = new ObjectMapper();
        // Convert object to JSON string
        String jsonStr = "";
        try {
            jsonStr =  mapper.writeValueAsString(obj);
        } catch (IOException e) {
            throw e;
        }
        return new JSONObject(jsonStr);
    }
}

+ 12 - 9
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java

@ -35,15 +35,8 @@ public class YueRenController extends BaseController {
    @RequestMapping(value = "/phonekey", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @RequestMapping(value = "/phonekey", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    @ResponseBody
    public String getPhoneKey() {
    public String getPhoneKey() {
        String postStr = remoteCall("/yueren/phonekey", new JSONObject());
        JSONObject jsonObject = new JSONObject(postStr);
        String status = jsonObject.get("status").toString();
        if ("200".equals(status)) {
            JSONObject recordset = jsonObject.getJSONObject("recordset");
            String key = recordset.getString("key");
            this.saveKey(key);
        }
        return postStr;
        String key =wlyyMedicineKeyService.getKey();
        return  write(200,"查询成功","key",key);
    }
    }
    /**
    /**
@ -55,6 +48,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String insertSlip(@RequestBody String jsonString) {
    public String insertSlip(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/insertslip", params);
        String postStr = remoteCall("/yueren/insertslip", params);
        return postStr;
        return postStr;
    }
    }
@ -83,6 +77,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String inserTemp(@RequestBody String jsonString) {
    public String inserTemp(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/dillphoneimgdata", params);
        String postStr = remoteCall("/yueren/dillphoneimgdata", params);
        return postStr;
        return postStr;
    }
    }
@ -98,6 +93,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String findTest(@RequestBody String jsonString) {
    public String findTest(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findtest", params);
        String postStr = remoteCall("/yueren/findtest", params);
        return postStr;
        return postStr;
    }
    }
@ -111,6 +107,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String giveproblem(@RequestBody String jsonString) {
    public String giveproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/giveproblem", params);
        String postStr = remoteCall("/yueren/giveproblem", params);
        return postStr;
        return postStr;
    }
    }
@ -124,6 +121,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String handleproblem(@RequestBody String jsonString) {
    public String handleproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/handleproblem", params);
        String postStr = remoteCall("/yueren/handleproblem", params);
        return postStr;
        return postStr;
    }
    }
@ -137,6 +135,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String centralizedproblem(@RequestBody String jsonString) {
    public String centralizedproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/centralizedproblem", params);
        String postStr = remoteCall("/yueren/centralizedproblem", params);
        return postStr;
        return postStr;
    }
    }
@ -150,6 +149,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String conclusionFactor(@RequestBody String jsonString) {
    public String conclusionFactor(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/conclusionfactor", params);
        String postStr = remoteCall("/yueren/conclusionfactor", params);
        return postStr;
        return postStr;
    }
    }
@ -165,6 +165,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String insertConsultConclusionHealth(@RequestBody String jsonString) {
    public String insertConsultConclusionHealth(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/insertconconhealth", params);
        String postStr = remoteCall("/yueren/insertconconhealth", params);
        return postStr;
        return postStr;
    }
    }
@ -178,6 +179,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String insertConsultConclusion(@RequestBody String jsonString) {
    public String insertConsultConclusion(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findconconhealth", params);
        String postStr = remoteCall("/yueren/findconconhealth", params);
        return postStr;
        return postStr;
    }
    }
@ -191,6 +193,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    @ResponseBody
    public String findIntegral(@RequestBody String jsonString) {
    public String findIntegral(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findintegral", params);
        String postStr = remoteCall("/yueren/findintegral", params);
        return postStr;
        return postStr;
    }
    }

+ 7 - 6
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/entity/WlyyMedicineKey.java

@ -1,7 +1,7 @@
package com.yihu.wlyy.medicine.entity;
package com.yihu.wlyy.medicine.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import javax.persistence.*;
import java.io.Serializable;
import java.io.Serializable;
@ -13,20 +13,21 @@ import java.util.Date;
@Entity
@Entity
@Table(name = "wlyy_medicine_key", schema = "", catalog = "medicine")
@Table(name = "wlyy_medicine_key", schema = "", catalog = "medicine")
public class WlyyMedicineKey implements Serializable {
public class WlyyMedicineKey implements Serializable {
    private Long id;
    private String id;
    private String accessKey;
    private String accessKey;
    private Long addTimestamp;
    private Long addTimestamp;
    private Long expiresIn;
    private Long expiresIn;
    private Date creataTime;
    private Date creataTime;
    @Id
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String getId() {
        return id;
        return id;
    }
    }
    public void setId(Long id) {
    public void setId(String id) {
        this.id = id;
        this.id = id;
    }
    }

+ 7 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/repository/WlyyMedicineKeyDao.java

@ -2,10 +2,17 @@ package com.yihu.wlyy.medicine.repository;
import com.yihu.wlyy.medicine.entity.WlyyMedicineKey;
import com.yihu.wlyy.medicine.entity.WlyyMedicineKey;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
/**
 * Created by Administrator on 2017/8/14.
 * Created by Administrator on 2017/8/14.
 */
 */
public interface WlyyMedicineKeyDao extends PagingAndSortingRepository<WlyyMedicineKey, Long>, JpaSpecificationExecutor<WlyyMedicineKey> {
public interface WlyyMedicineKeyDao extends PagingAndSortingRepository<WlyyMedicineKey, Long>, JpaSpecificationExecutor<WlyyMedicineKey> {
    @Query("select w from WlyyMedicineKey w order by w.addTimestamp desc")
    List<WlyyMedicineKey> findAll();
}
}

+ 4 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java

@ -39,6 +39,7 @@ public class FamilyMemberService extends BaseService {
    @Autowired
    @Autowired
    FamilyContractService contractService;
    FamilyContractService contractService;
    @Autowired
    private HosDoctorService hosDoctorService;
    private HosDoctorService hosDoctorService;
    Map<Integer, String> relations = new HashMap<>();
    Map<Integer, String> relations = new HashMap<>();
@ -126,7 +127,7 @@ public class FamilyMemberService extends BaseService {
        return list;
        return list;
    }
    }
    public Map getPatient(String patient){
    public Map getPatient(String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        Patient p = patientDao.findByCode(patient);
        //查询签约信息
        //查询签约信息
@ -144,6 +145,8 @@ public class FamilyMemberService extends BaseService {
        }
        }
        map.put("doctor",doctor);
        map.put("doctor",doctor);
        map.put("doctorName",doctorName);
        map.put("doctorName",doctorName);
        Doctor _doctor = hosDoctorService.getDoctorByCode(doctor);
        map.put("doctorMobile",_doctor.getMobile());
        map.put("code", p.getCode());
        map.put("code", p.getCode());
        map.put("name", p.getName());
        map.put("name", p.getName());
        map.put("sex", p.getSex());
        map.put("sex", p.getSex());

+ 32 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/medicine/WlyyMedicineKeyService.java

@ -2,19 +2,25 @@ package com.yihu.wlyy.service.manager.medicine;
import com.yihu.wlyy.medicine.entity.WlyyMedicineKey;
import com.yihu.wlyy.medicine.entity.WlyyMedicineKey;
import com.yihu.wlyy.medicine.repository.WlyyMedicineKeyDao;
import com.yihu.wlyy.medicine.repository.WlyyMedicineKeyDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.query.BasemedicineJpaService;
import com.yihu.wlyy.util.query.BasemedicineJpaService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springside.modules.utils.Clock;
import org.springside.modules.utils.Clock;
import javax.annotation.Resource;
import java.util.List;
/**
/**
 * Created by Administrator on 2017/8/14.
 * Created by Administrator on 2017/8/14.
 */
 */
@Service
@Service
public class WlyyMedicineKeyService extends BasemedicineJpaService<WlyyMedicineKey, WlyyMedicineKeyDao> {
public class WlyyMedicineKeyService extends BasemedicineJpaService<WlyyMedicineKey, WlyyMedicineKeyDao> {
    @Value("${yueren.api}")
    private String api;
    @Autowired
    @Autowired
    private WlyyMedicineKeyDao wlyyMedicineKeyDao;
    private WlyyMedicineKeyDao wlyyMedicineKeyDao;
@ -28,4 +34,28 @@ public class WlyyMedicineKeyService extends BasemedicineJpaService<WlyyMedicineK
        medicineKey.setCreataTime(clock.getCurrentDate());
        medicineKey.setCreataTime(clock.getCurrentDate());
        wlyyMedicineKeyDao.save(medicineKey);
        wlyyMedicineKeyDao.save(medicineKey);
    }
    }
    public String getKey() {
        String key="";
        List<WlyyMedicineKey> wlyyMedicineKeys = wlyyMedicineKeyDao.findAll();
        if(wlyyMedicineKeys!=null && wlyyMedicineKeys.size()>0){
            for (WlyyMedicineKey wlyyMedicineKey : wlyyMedicineKeys) {
                if ((System.currentTimeMillis() - wlyyMedicineKey.getAddTimestamp()) < (wlyyMedicineKey.getExpiresIn() * 1000)) {
                    return wlyyMedicineKey.getAccessKey();
                } else {
                    wlyyMedicineKeyDao.delete(wlyyMedicineKey);
                }
            }
        }
        String postStr = HttpClientUtil.postBody(api + "/yueren/phonekey", new JSONObject());
        JSONObject jsonObject = new JSONObject(postStr);
        String status = jsonObject.get("status").toString();
        if ("200".equals(status)) {
            JSONObject recordset = jsonObject.getJSONObject("recordset");
            key = recordset.getString("key");
            this.saveKey(key);
        }
        return key;
    }
}
}

+ 4 - 4
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java

@ -1,9 +1,5 @@
package com.yihu.wlyy.util;
package com.yihu.wlyy.util;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.ParseException;
@ -20,6 +16,10 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
public class HttpClientUtil {
public class HttpClientUtil {
	/**
	/**