Browse Source

统计代码提交

chenweida 8 years ago
parent
commit
3928865843

+ 12 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -7,6 +7,7 @@ package com.yihu.wlyy.repository.patient;
import java.util.List;
import com.yihu.wlyy.entity.patient.Patient;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
@ -47,6 +48,16 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	@Query("select a from SignFamily a where a.doctorHealth = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
	SignFamily findByDoctorHealthPatient(String doctor, String patient);
	@Query("select p from Patient p,SignFamily a where a.doctorHealth = ?1 and a.patient =p.code and a.type = 2 and a.status >= 0")
	List<Patient> findByDoctorHealthPatient(String doctor);
	@Query("select p from Patient p,SignFamily a where (a.doctorHealth = ?1 or a.doctor=?2 ) and a.patient =p.code and a.type = 2 and a.status >= 0")
	List<Patient> findByDoctorOrDoctorHealthPatient(String doctorHealth,String doctor);
	@Query("select p from Patient p,SignFamily a where a.doctor = ?1 and a.patient =p.code and a.type = 2 and a.status >= 0")
	List<Patient> findByDoctorPatient(String doctor);
	@Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 1 and a.status > 0")
	SignFamily findSsSignByDoctorPatient(String doctor, String patient);
@ -319,4 +330,5 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	 * @return
	 */
	List<SignFamily> findByAdminTeamIdAndStatus(long teamCode,int status);
}

+ 116 - 19
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -4,14 +4,11 @@ import java.util.*;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.doctor.team.sign.*;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.profile.DoctorService;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
@ -91,8 +88,6 @@ public class FamilyContractService extends BaseService {
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyySignFamilyCodeDao wlyySignFamilyCodeDao;
    @Autowired
    private SystemDictDao systemDictDao;
@ -110,6 +105,14 @@ public class FamilyContractService extends BaseService {
    MessageService messageService;
    @Autowired
    AdminTeamService adminTeamService;
    @Autowired
    SignPatientLabelDao labelDao;
    @Autowired
    SignPatientLabelLogDao labelLogDao;
    @Autowired
    SignPatientLabelInfoDao labelInfoDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    public SignFamily findSignFamilyByCode(String code) {
        return signFamilyDao.findByCodeAndType(code, 2);
@ -1953,10 +1956,10 @@ public class FamilyContractService extends BaseService {
            }
        }
        if(docMap.size() > 0){
            result.put("teamDoctors",new JSONArray(docMap.values()));
        if (docMap.size() > 0) {
            result.put("teamDoctors", new JSONArray(docMap.values()));
        } else {
            result.put("teamDoctors",new JSONArray());
            result.put("teamDoctors", new JSONArray());
        }
        return result;
@ -1978,34 +1981,128 @@ public class FamilyContractService extends BaseService {
        if (ssSign != null) {
            JSONObject qkDoc = new JSONObject();
            qkDoc.put("doctor",ssSign.getDoctor());
            qkDoc.put("doctorName",ssSign.getDoctorName());
            qkDoc.put("doctor", ssSign.getDoctor());
            qkDoc.put("doctorName", ssSign.getDoctorName());
            ssArray.put("doctor", qkDoc);
            JSONObject jgDoc = new JSONObject();
            jgDoc.put("doctor",ssSign.getDoctorHealth());
            jgDoc.put("doctorName",ssSign.getDoctorHealthName());
            jgDoc.put("doctor", ssSign.getDoctorHealth());
            jgDoc.put("doctorName", ssSign.getDoctorHealthName());
            ssArray.put("doctorHealth", jgDoc);
        }
        if (jtSign != null) {
            JSONObject qkDoc = new JSONObject();
            qkDoc.put("doctor",jtSign.getDoctor());
            qkDoc.put("doctorName",jtSign.getDoctorName());
            qkDoc.put("doctor", jtSign.getDoctor());
            qkDoc.put("doctorName", jtSign.getDoctorName());
            jtArray.put("doctor", qkDoc);
            JSONObject jgDoc = new JSONObject();
            jgDoc.put("doctor",jtSign.getDoctorHealth());
            jgDoc.put("doctorName",jtSign.getDoctorHealthName());
            jgDoc.put("doctor", jtSign.getDoctorHealth());
            jgDoc.put("doctorName", jtSign.getDoctorHealthName());
            jtArray.put("doctorHealth", jgDoc);
        }
        result.put("ssSign",ssArray);
        result.put("jtSign",jtSign);
        result.put("ssSign", ssArray);
        result.put("jtSign", jtSign);
        return result;
    }
    public Map<String, List<Patient>> getPatientByLevel(String doctorCode) {
        Map<String, List<Patient>> returnMap = new HashMap<>();
        Doctor doctor = doctorDao.findByCode(doctorCode);
        //判断当前用户是健康管理师还是全科
        if (doctor.getLevel() == 3) {
            //健康管理师
            List<Patient> jkgl = signFamilyDao.findByDoctorHealthPatient(doctorCode);
            returnMap.put("jk", jkgl);
        } else if (doctor.getLevel() == 2) {
            //全科医生
            List<Patient> qkys = signFamilyDao.findByDoctorPatient(doctorCode);
            returnMap.put("qk", qkys);
            //健康管理师
            List<Patient> jkgl = signFamilyDao.findByDoctorHealthPatient(doctorCode);
            returnMap.put("jk", jkgl);
        }
        return returnMap;
    }
    public JSONObject getPatientByLable(String doctorCode, String labelType) throws Exception {
        JSONObject returnMap = new JSONObject();
        Doctor doctor = doctorDao.findByCode(doctorCode);
        //判断当前用户是健康管理师还是全科
        List<Map<String, Object>> datas = null;
        if (doctor.getLevel() == 3) {
            //健康管理师
            String sql = "SELECT sf. CODE signcode, " +
                    " p.`name` name, " +
                    " p. CODE `code`, " +
                    " case p.openid when null then 0 when \"\" then 0 else 1 end hasopenid, "+
                    " sp.id labelid, " +
                    " sp.label_name labelname, " +
                    " sp.label_type labeltype, "+
                    " p.idcard idcard " +
           " FROM " +
                    " wlyy_sign_family sf, " +
                    " wlyy_patient p, " +
                    " wlyy_sign_patient_label_info sp " +
           " WHERE" +
                    " sf.patient = p.CODE " +
                    " AND p. CODE = sp.patient " +
                    " AND sf.type = 2 " +
                    " AND sf. STATUS >= 0 " +
                    " and sp.`status`=1 " +
                    " and sf.doctor_health = ? " +
                    " and sp.label_type= ?";
            //查找居民
            datas = jdbcTemplate.queryForList(sql, doctorCode, labelType);
        } else if (doctor.getLevel() == 2) {
            //健康管理师
            String sql = "SELECT sf. CODE signcode, " +
                    " p.`name` name, " +
                    " p. CODE `code`, " +
                    " sp.id labelid, " +
                    " sp.label_name labelname, " +
                    " case p.openid when null then 0 when \"\" then 0 else 1 end hasopenid, "+
                    " sp.label_type labeltype, "+
                    " p.idcard idcard " +
            " FROM " +
                    " wlyy_sign_family sf, " +
                    " wlyy_patient p, " +
                    " wlyy_sign_patient_label_info sp " +
            " WHERE" +
                    " sf.patient = p.CODE " +
                    " AND p. CODE = sp.patient " +
                    " AND sf.type = 2 " +
                    " AND sf. STATUS >= 0 " +
                    " and sp.`status`=1 " +
                    " and ( sf.doctor = ? or sf.doctor_health = ? ) " +
                    " and sp.label_type= ?";
            //查找居民
            datas = jdbcTemplate.queryForList(sql, doctorCode,doctorCode, labelType);
        } else {
            throw new Exception("参数错误");
        }
        //根据类别查找标签
        List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatus(labelType, 1);
        if (s != null && s.size() > 0) {
            for (SignPatientLabel one : s) {
                returnMap.put(one.getLabelCode(), new JSONArray());
            }
            if (datas != null && datas.size() > 0) {
                for (Map<String, Object> map : datas) {
                    JSONObject jo=new JSONObject(map);
                    returnMap.getJSONArray(jo.get("labeltype").toString()).put(jo);;
                }
            }
        }
        return returnMap;
    }
}

+ 59 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -64,6 +64,65 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    @Autowired
    AdminTeamService teamService;
    /**
     * 查看当前医生签约的居民
     */
    @RequestMapping(value = "getPatientByLevel")
    @ResponseBody
    public String getPatientByLevel() {
        try {
            JSONObject returnJO = new JSONObject();
            Map<String, List<Patient>> list = familyContractService.getPatientByLevel(getUID());
            if(list!=null&&list.size()>0){
                for(Map.Entry<String, List<Patient>> entyr:list.entrySet()) {
                    JSONArray array = new JSONArray();
                    addList(returnJO, entyr.getValue(), array, entyr.getKey());
                }
            }
            return write(200, "签约数据加载成功!", "data", returnJO);
        } catch (Exception e) {
            error(e);
            return error(-1, "签约数据加载失败!");
        }
    }
    private void addList(JSONObject returnJO, List<Patient> pts, JSONArray array, String key) {
        if (pts != null && pts.size() > 0) {
            for (Patient sf : pts) {
                if (sf == null) {
                    continue;
                }
                JSONObject json = new JSONObject();
                json.put("id", sf.getId());
                // 签约患者标识
                json.put("code", sf.getCode());
                // 签约患者名称
                json.put("name", sf.getName());
                // 签约患者头像
                json.put("photo", sf.getPhoto());
                // 签约患者性别
                json.put("sex", sf.getSex());
                // 签约患者性别
                json.put("age", IdCardUtil.getAgeForIdcard(sf.getIdcard()));
                array.put(json);
            }
            returnJO.put(key, array);
        }
    }
    /**
     * 根据标签查看当前医生签约的居民
     */
    @RequestMapping(value = "/getPatientByLable")
    @ResponseBody
    public String getPatientByLable(String labelType) {
        try {
            JSONObject list = familyContractService.getPatientByLable("D20161008002", labelType);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    /**
     * 医生签约患者列表查询接口
     *