Browse Source

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

chenweida 8 years ago
parent
commit
f0cc512e0f

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

@ -1,7 +1,8 @@
package com.yihu.mm.controller.medicine;
import com.yihu.mm.controller.BaseController;
import com.yihu.mm.entity.Patient;
import com.yihu.mm.entity.PatientExam;
import com.yihu.mm.service.PatientExamService;
import com.yihu.mm.service.PatientService;
import com.yihu.mm.service.PhysicalExaminationService;
import com.yihu.mm.util.HttpClientUtil;
@ -35,6 +36,9 @@ public class PhysicalExaminationController extends BaseController {
    @Autowired
    private PhysicalExaminationService physicalExaminationService;
    @Autowired
    private PatientExamService patientExamService;
    @ApiOperation(value = "获取试卷列表")
    @RequestMapping(value = "/findExames",produces="application/json;charset=UTF-8")
@ -45,7 +49,16 @@ public class PhysicalExaminationController extends BaseController {
        HttpSession session = req.getSession();
        String key = (String) session.getAttribute("key");
        if(StringUtils.isBlank(key)){
            key = HttpClientUtil.postBody(yuerenApi + "/phonekey", new JSONObject());
            //通过接口查询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);
        }
@ -57,20 +70,44 @@ public class PhysicalExaminationController extends BaseController {
    @ResponseBody
    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");
        Patient patient = patientService.findByCode(patientCode);
        return physicalExaminationService.insertslip(key,patient);
        //Patient patient = patientService.findByCode(patientCode);
        //return physicalExaminationService.insertslip(key,patient);
        return null;
    }
    @ApiOperation(value = "获取试题")
    @RequestMapping(value = "/findQuestion",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = false, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = false, name = "pb_id") String pb_id,
                               @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = false, name = "ct_id") String ct_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 = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                               HttpServletRequest req){
        String key = (String) req.getSession().getAttribute("key");
        return physicalExaminationService.findQuestion(key,tp_id,pb_id,ct_id);
        HttpSession session = req.getSession();
        String key = (String) session.getAttribute("key");
        String ct_id="";
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        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;
            //}
        }
        String question = physicalExaminationService.findQuestion(key, tp_id, pb_id, ct_id);
        return question;
    }
    @ApiOperation(value = "提交试卷答案")
@ -79,11 +116,15 @@ public class PhysicalExaminationController extends BaseController {
    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 = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id,
                             @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                            HttpServletRequest req){
        String key = (String) req.getSession().getAttribute("key");
        return physicalExaminationService.handleExam(key,tp_id,pb_id,dc_answer,ct_id);
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        String ct_id = patientExam.getCtId();
        String result = physicalExaminationService.handleExam(key, tp_id, pb_id, dc_answer, ct_id);
        return result;
    }
    @ApiOperation(value = "四诊资料采集")

+ 57 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/entity/PatientExam.java

@ -0,0 +1,57 @@
package com.yihu.mm.entity;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name = "patient_exam")
public class PatientExam extends IdEntity implements Serializable {
    @Column(name="patient")
    private String patient;
    @Column(name="tp_id")
    private String tpId;
    @Column(name="ct_id")
    private String ctId;
    @Column(name="is_complete")
    private Integer isComplete;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getTpId() {
        return tpId;
    }
    public void setTpId(String tpId) {
        this.tpId = tpId;
    }
    public String getCtId() {
        return ctId;
    }
    public void setCtId(String ctId) {
        this.ctId = ctId;
    }
    public Integer getIsComplete() {
        return isComplete;
    }
    public void setIsComplete(Integer isComplete) {
        this.isComplete = isComplete;
    }
}

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

@ -0,0 +1,19 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.repository;
import com.yihu.mm.entity.PatientExam;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface PatientExamDao extends PagingAndSortingRepository<PatientExam, Long>,JpaSpecificationExecutor<PatientExam> {
	// 查询患者code和试卷编号查询
	@Query("select p from PatientExam p where p.code=?1 and p.tpId=?2")
	PatientExam findByPatientAndTpId(String code, String tpId);
}

+ 84 - 5
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/wlyy/patient/PatientDao.java

@ -1,10 +1,89 @@
package com.yihu.mm.repository.wlyy.patient;
import com.yihu.wlyy.entity.patient.Patient;
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
import com.yihu.mm.entity.Patient;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/8/8.
 */
public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
import java.util.List;
public interface PatientDao extends PagingAndSortingRepository<Patient, Long>,JpaSpecificationExecutor<Patient> {
    // 查询患者姓名
    @Query("select p.name from Patient p where p.code=?1")
    String findNameByCode(String code);
    // 根据姓名查询
    @Query("select p.code from Patient p where p.name=?1")
    String[] findByName(String name);
    // 根據患者標識查詢患者信息
    @Query("select p from Patient p where p.code=?1")
    Patient findByCode(String code);
    // 根據患者標識查詢患者信息
    @Query("select p from Patient p where p.code=?1 and p.idcard =?2")
    Patient findByCodeAndIdcard(String code, String idcard);
    // 根據身份證號查詢患者信息
    @Query("select p from Patient p where p.idcard=?1")
    Patient findByIdcard(String idcard);
    @Query("select p from Patient p where p.ssc=?1")
    Patient findBySsc(String ssc);
    // 根據手机号查詢患者信息
    @Query("select p from Patient p where p.mobile=?1")
    Patient findByMobile(String mobile);
    // 根據病情等级获取患者信息
    @Query("select p from Patient p where p.diseaseCondition=?1")
    Iterable<Patient> findInfoByLevel(int level);
    @Query("select p from Patient p where p.openid=?1")
    Patient findByOpenid(String openid);
    @Query("select count(1) from Patient p where p.openid=?1")
    int countByOpenid(String openid);
    //清空openid
    @Modifying
    @Query("update Patient p set p.openid = null where p.code <> ?1 and p.openid = ?2")
    int clearOpenid(String patient, String openid);
    @Modifying
    @Query(value = "update Patient p set p.status=?1 where p.id=?2 ")
    int updateStatus(Integer status, Long id);
    @Modifying
    @Query(value = "update Patient p set p.password=?1,p.salt=?2 where p.id=?3 ")
    int initPassword(String password, String salt, Long id);
    @Query(value = "select count(1) from Patient p where p.mobile = ?1")
    int isMobileExist(String mobile);
    @Query(value = "select count(1) from Patient p where p.idcard = ?1")
    int isIdCardExist(String idcard);
    @Query(value = "select count(1) from Patient p where p.ssc = ?1")
    int isSscExist(String ssc);
    @Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!='' ")
    List<Patient> findByCity(String city);
    @Query("select p from Patient p where p.city = ?1 and p.mobile is not null and p.mobile!=''  and p.town in ?2 ")
    List<Patient> findByCityAndTowns(String city, String towns[]);
    @Query(value = "SELECT DISTINCT p.* from wlyy_patient p LEFT JOIN wlyy_sign_family f on p.code = f.patient WHERE p.city = ?1 and p.mobile is not null and p.mobile!=''  and f.hospital in ?2 ",nativeQuery = true)
    List<Patient> findByCityAndHospital(String city, String hospital[]);
    @Query("select p from Patient p where p.idcard=?1 and p.ssc=?2")
    Patient findByIdcardAndSsc(String idcard, String ssc);
}

+ 36 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PatientExamService.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.PatientExam;
import com.yihu.mm.repository.PatientExamDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.persistence.Transient;
/**
 * 患者基本信息类.
 *
 * @author George
 */
@Service
public class PatientExamService{
    @Autowired
    private PatientExamDao patientExamDao;
    public PatientExam findByPatientAndTpId(String patientCode,String tpId){
        return patientExamDao.findByPatientAndTpId(patientCode,tpId);
    }
    @Transient
    public void save(PatientExam patientExam){
         patientExamDao.save(patientExam);
    }
}

+ 3 - 1
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PatientService.java

@ -6,8 +6,9 @@
package com.yihu.mm.service;
import com.yihu.mm.dao.PatientDao;
import com.yihu.mm.entity.Patient;
import com.yihu.mm.repository.wlyy.patient.PatientDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -18,6 +19,7 @@ import org.springframework.stereotype.Service;
@Service
public class PatientService {
    @Autowired
    private PatientDao patientDao;
    public Patient findByCode(String code) {

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

@ -17,13 +17,11 @@ public class PhysicalExaminationService {
    public String findExames(String key,String type, String examCode) {
        //先获取key值
        JSONObject params = new JSONObject();
        params.put("key",key);
        params.put("tp_type", type);
        params.put("sh_id", examCode);
        return HttpClientUtil.postBody(yuerenApi + "/findtest", params);
    }
    public String insertslip(String key,Patient patient) {

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

@ -1,10 +1,12 @@
package com.yihu.wlyy.service.manager.family;
import com.yihu.wlyy.entity.Doctor;
import com.yihu.wlyy.entity.Patient;
import com.yihu.wlyy.entity.SignFamily;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.repository.PatientFamilyMemberDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.manager.hos.HosDoctorService;
import com.yihu.wlyy.service.manager.sign.FamilyContractService;
import com.yihu.wlyy.util.CommonUtil;
import org.apache.commons.lang3.StringUtils;
@ -37,6 +39,8 @@ public class FamilyMemberService extends BaseService {
    @Autowired
    FamilyContractService contractService;
    private HosDoctorService hosDoctorService;
    Map<Integer, String> relations = new HashMap<>();
@ -59,7 +63,7 @@ public class FamilyMemberService extends BaseService {
     * @param patient
     * @return
     */
    public List<Map<String,Object>> getAllFamilyMembers(String patient){
    public List<Map<String,Object>> getAllFamilyMembers(String patient) throws Exception {
        List<Map<String,Object>> list = new ArrayList<>();
        list.add(getPatient(patient));
@ -89,8 +93,11 @@ public class FamilyMemberService extends BaseService {
                        jtSign = true;
                    }
                    map1.put("statusName","已签约");
                    map1.put("doctor",sign.getDoctor());
                    String doctorCode = sign.getDoctor();
                    map1.put("doctor",doctorCode);
                    map1.put("doctorName",sign.getDoctorName());
                    Doctor doctor = hosDoctorService.getDoctorByCode(doctorCode);
                    map1.put("doctorMobile",doctor.getMobile());
                }
                Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
                map1.put("code", map.get("code"));