Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

wujunjie 7 years ago
parent
commit
c1baa341c1
23 changed files with 727 additions and 174 deletions
  1. 4 4
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/health/DoctorHealthStandard.java
  2. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/admin/AdminTeam.java
  3. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java
  4. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java
  5. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctroSchemeBloodSuggerDao.java
  6. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  7. 13 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  8. 38 38
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  9. 107 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  10. 193 36
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java
  11. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  12. 48 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  13. 43 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  14. 8 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  15. 114 57
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  16. 14 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSignService.java
  17. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  18. 11 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  19. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  20. 25 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  21. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  22. 63 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  23. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

+ 4 - 4
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/health/DoctorHealthStandard.java

@ -22,13 +22,13 @@ public class DoctorHealthStandard extends IdEntity {
    private String doctor;
    // 健康指标类型:1血糖,2血压,3体重,4腰围
    private Integer type;
    // 最低安全值(血糖餐前\收缩压\体重\腰围)
    // 最低安全值(血糖餐前\收缩压\BMI\腰围)
    private Double minValue1;
    // 最高安全值(血糖餐前\收缩压\体重\腰围)
    // 最高安全值(血糖餐前\收缩压\BMI\腰围)
    private Double maxValue1;
    // 最低安全值(血糖餐后\舒张压)
    // 最低安全值(血糖餐后\舒张压\步数)
    private Double minValue2;
    // 最高安全值(血糖餐后\舒张压)
    // 最高安全值(血糖餐后\舒张压\步数)
    private Double maxValue2;
    // 设置时间
    private Date czrq;

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/admin/AdminTeam.java

@ -26,6 +26,7 @@ public class AdminTeam extends IdEntity {
    private String orgName;
    private String townCode;
    private String townName;
    private String mappingCode;
    public String getName() {
        return name;
@ -78,6 +79,15 @@ public class AdminTeam extends IdEntity {
        this.available = available;
    }
    @Column(name = "mapping_code")
    public String getMappingCode() {
        return mappingCode;
    }
    public void setMappingCode(String mappingCode) {
        this.mappingCode = mappingCode;
    }
    @Transient
    public String getOrgName() {
        return orgName;

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -98,4 +98,6 @@ public interface DevicePatientHealthIndexDao
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from device.wlyy_patient_health_index a where a.user = ?1 and a.record_date >= ?2 and a.record_date <= ?3 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?4 ,?5",nativeQuery = true)
	List<String> findDateList(String patient,Date start ,Date end,int currentSize,int pageSize);
	@Query(value= " select * from device.wlyy_patient_health_index where type in (?1) and record_date BETWEEN ?2 AND ?3  AND user in (select p.code from wlyy_patient p INNER JOIN wlyy_sign_family s on s.patient = p.code and s.status > 0 AND s.admin_team_code = ?4 and p.disease >0)",nativeQuery = true)
	List<DevicePatientHealthIndex> findByTeamcodeAndRecordDate(String type ,Date start, Date end,String teamcode);
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java

@ -20,5 +20,5 @@ public interface DoctoreSchemeBloodPressureDao extends
    List<DoctorSchemeBloodPressure> getListByDoctorcode(String doctorCode);
    @Query(" from DoctorSchemeBloodPressure p where p.code=?1")
    DoctorSchemeBloodPressure findByCode(String code);
    List<DoctorSchemeBloodPressure> findByCode(String code);
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctroSchemeBloodSuggerDao.java

@ -25,5 +25,5 @@ public interface DoctroSchemeBloodSuggerDao extends
    List<DoctorSchemeBloodSugger> getListByDoctorcode(String doctorcode);
    @Query(" from DoctorSchemeBloodSugger p where p.code=?1")
    DoctorSchemeBloodSugger findByCode(String code);
    List<DoctorSchemeBloodSugger> findByCode(String code);
}

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

@ -64,4 +64,7 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    //获取所有的openid并排重
    @Query("select distinct p.openid from Patient p where p.openid is not null and p.openid <> '' ")
    List<String> findOpenids();
    @Query(" select p from Patient p,SignFamily s where p.code=s.patient and s.status > 0 and s.adminTeamId = ?1 and p.disease > 0")
    List<Patient> findAllSignPatientTeamcode(String teamcode);
}

+ 13 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -743,16 +743,21 @@ public class PatientHealthIndexService extends BaseService {
                    DecimalFormat df1 = new DecimalFormat("###.00");
                    obj.setValue3(df1.format(bmi));
                    double bmiMin = new Double("18.5");
                    double bmiMax = new Double("23.9");
                    if(patientAimSports != null && StringUtils.isNoneEmpty(patientAimSports.getCode())){
                        bmiMin = Double.parseDouble(patientAimSports.getBmiMin());
                        bmiMax = Double.parseDouble(patientAimSports.getBmiMax());
                    }
                        //设置BMI值
                        if(bmi < Double.parseDouble(patientAimSports.getBmiMin())){
                            obj.setValue4("1");
                        }else if(bmi > Double.parseDouble(patientAimSports.getBmiMax())){
                            obj.setValue4("-1");
                        }else{
                            obj.setValue4("0");
                        }
                    //设置BMI值
                    if(bmi < bmiMin){
                        obj.setValue4("1");
                    }else if(bmi > bmiMax){
                        obj.setValue4("-1");
                    }else{
                        obj.setValue4("0");
                    }
                    break;

+ 38 - 38
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -307,8 +307,10 @@ public class SignPatientLabelInfoService extends BaseService {
                    "   t1.doctor = ? " +
                    "   OR t1.doctor_health = ? " +
                    "  ) " +
                    "  AND t1. STATUS > 0 " +
                    "  AND t1.admin_team_code = ?" ;
                    "  AND t1. STATUS > 0  AND t1.admin_team_code = ?";
            if(isSlowDisease){
                sql = sql + "  AND p.diease >0 " ;
            }
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.disease_condition ="+diseaseCondition;
            }
@ -356,14 +358,13 @@ public class SignPatientLabelInfoService extends BaseService {
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        String _pdsql = "select user,floor(sum(category_code)) deviceType FROM wlyy_patient_device GROUP BY user";
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<Map<String,Object>> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                System.out.println(user+sum);
                patientDeviceTypeMap.put(user,sum);
            }
        }
@ -481,9 +482,9 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
@ -530,20 +531,18 @@ public class SignPatientLabelInfoService extends BaseService {
                    //判断预警状态
                    if(standardStatus1 == standardStatus2){
                        //判断病种种类
                        if(disease1 == disease2){
                            //判断颜色标签
                            if(diseaseCondition1 == diseaseCondition2){
                        //判断颜色标签
                        if(diseaseCondition1 == diseaseCondition2){
                            //判断病种种类
                            if(disease1 == disease2){
                                //判断微信绑定情况
                                re = openid1.compareTo(openid2);
                            }else{
                                re = diseaseCondition1 - diseaseCondition2;
                                re = disease2 - disease1;
                            }
                        }else{
                            re = disease1 - disease2;
                            re = diseaseCondition2 - diseaseCondition1;
                        }
                    }else{
                        re = standardStatus1 - standardStatus2;
                    }
@ -3583,7 +3582,7 @@ public class SignPatientLabelInfoService extends BaseService {
     * @return
     * @throws Exception
     */
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize, boolean sortByStandardStatus, String diseaseCondition) throws Exception {
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize, boolean isSlowDisease, String diseaseCondition) throws Exception {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
@ -3643,6 +3642,9 @@ public class SignPatientLabelInfoService extends BaseService {
            }else{
                args = new Object[]{teamCode};
            }
            if(isSlowDisease){
                sql = sql + " AND p.disease >0 ";
            }
            sql = sql +
                    " ) f " +
                    "WHERE " +
@ -3706,7 +3708,6 @@ public class SignPatientLabelInfoService extends BaseService {
            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                System.out.println(user+sum);
                patientDeviceTypeMap.put(user,sum);
            }
        }
@ -3825,9 +3826,9 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
@ -3875,18 +3876,19 @@ public class SignPatientLabelInfoService extends BaseService {
                    //判断预警状态
                    if(standardStatus1 == standardStatus2){
                        //判断病种种类
                        if(disease1 == disease2){
                            //判断颜色标签
                            if(diseaseCondition1 == diseaseCondition2){
                        //判断颜色标签
                        if(diseaseCondition1 == diseaseCondition2){
                            //判断病种种类
                            if(disease1 == disease2){
                                //判断微信绑定情况
                                re = openid1.compareTo(openid2);
                            }else{
                                re = diseaseCondition1 - diseaseCondition2;
                                re = disease2 - disease1;
                            }
                        }else{
                            re = disease1 - disease2;
                            re = diseaseCondition2 - diseaseCondition1;
                        }
                    }else{
@ -4094,10 +4096,11 @@ public class SignPatientLabelInfoService extends BaseService {
                "    (t1.doctor = ? or t1.doctor_health = ?) " +
                "    AND t1.status > 0 " +
                "    AND t2.status = 1) " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : " AND (t2.label = 4 or t2.label = 5 )") +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "")+
                (StringUtils.isNotEmpty(diseaseCondition) ? " AND t3.diseaseCondition = ? " : "");
        sql = sql + " AND t3.disease > 0 AND t3.status > 0 ";
        if (matcher.find()) {
            sql = sql + "  AND (t1.idcard like ?) ";
@ -4130,11 +4133,11 @@ public class SignPatientLabelInfoService extends BaseService {
                }
            }
            sql = sql + " order by t3.diseaseCondition,t3.disease,t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            sql = sql + " order by t3.standard_status,t3.disease_condition,t3.disease,t3.openid desc limit " + page + "," + pagesize;
            signList = jdbcTemplate.queryForList(sql, argsnew);
        }else{
            sql = sql + " order by t3.diseaseCondition,t3.disease,t3.diseaseCondition,t3.openid desc limit " + page + "," + pagesize;
            sql = sql + " order by t3.standard_status,t3.disease_condition,t3.disease,t3.openid desc limit " + page + "," + pagesize;
            signList = jdbcTemplate.queryForList(sql, args);
        }
@ -4146,7 +4149,6 @@ public class SignPatientLabelInfoService extends BaseService {
            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                System.out.println(user+sum);
                patientDeviceTypeMap.put(user,sum);
            }
        }
@ -4287,9 +4289,9 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
@ -4339,17 +4341,16 @@ public class SignPatientLabelInfoService extends BaseService {
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_patiend t2 ON t1.patient = t2.code " +
                (isIdcard ? ",wlyy_patient p " : "") +
                " WHERE " +
                (isIdcard ? " t1.patient = p.code  and " : "") +
                (isIdcard ? " t1.patient = t2.code  and " : "") +
                "    t1.status > 0 " +
                " AND t1.admin_team_code = ? " +
                "  AND" +
                (isIdcard ? " p.idcard like ? " : " t1.name like ? ");
                (isIdcard ? " t2.idcard like ? " : " t1.name like ? ");
        sqlTemp = sqlTemp + " AND p.disease_condition = "+diseaseCondition;
        sqlTemp = sqlTemp + " AND t2.disease_condition = "+diseaseCondition+" AND t2.diease >0 AND t2.status >0 ";
        String sql = sqlTemp + " order by t2.diseaseCondition,t2.disease,t2,diseaseCondition,t2.openid desc  limit " + page + "," + pagesize;
        String sql = sqlTemp + " order by t2.standard_status,t2.disease_condition,t2.disease,t2.openid desc  limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
@ -4360,7 +4361,6 @@ public class SignPatientLabelInfoService extends BaseService {
            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                System.out.println(user+sum);
                patientDeviceTypeMap.put(user,sum);
            }
        }
@ -4485,9 +4485,9 @@ public class SignPatientLabelInfoService extends BaseService {
                //预警状态
                json.put("standardStatus",p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                Integer deviceType = 0;
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (Integer) patientDeviceTypeMap.get(p.getCode());
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);

+ 107 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -293,6 +293,113 @@ public class PrescriptionInfoService extends BaseService {
        return new com.alibaba.fastjson.JSONArray();
    }
    /**
     * 获取处方列表
     * @param patientCode
     * @param applyTimeFrom
     * @param applyTimeEnd
     * @param pageNo
     * @param pageSize
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject getRecipeMasterList(String patientCode,String applyTimeFrom,String applyTimeEnd,
               String isRenewal,String diagnosisCode,Integer pageNo,Integer pageSize) throws Exception{
        Patient patient = patientDao.findByCode(patientCode);
        if(pageNo==null||pageNo<=0){
            pageNo = 0;
        }
        pageNo++;
        if(pageSize==null||pageSize<=0){
            pageSize = 5;
        }
        Integer start = (pageNo-1)*pageSize;
        Integer end = pageNo*pageSize;
        Integer totalCount = 0;
        Integer newtotalCount = 0;
        com.alibaba.fastjson.JSONObject returnJson = new com.alibaba.fastjson.JSONObject();
        com.alibaba.fastjson.JSONArray filterJsonArray = new com.alibaba.fastjson.JSONArray();
        com.alibaba.fastjson.JSONObject re = jwPrescriptionService.getRecipeMasterList(patientCode,applyTimeFrom,applyTimeFrom);
        totalCount = re.getInteger("totalCount");
        if(totalCount>start){
            com.alibaba.fastjson.JSONArray pres = re.getJSONArray("list");
            for (int i = 0; i < pres.size(); i++) {
                com.alibaba.fastjson.JSONObject r = (com.alibaba.fastjson.JSONObject) pres.get(i);
                String rState = presCheckStateObj(r.getString("code"));
                r.put("patientName", patient.getName());
                r.put("patient", patient.getCode());
                if ("1".equals(rState)) {
                    r.put("reviewedState", 1);
                    r.put("prescriptionCode", "");
                } else {
                    r.put("reviewedState", 0);
                    r.put("prescriptionCode", rState);
                }
                com.alibaba.fastjson.JSONArray des = r.getJSONArray("prescriptionDt");
                //过滤可续签
                if (StringUtils.isNotBlank(isRenewal) && "1".equals(isRenewal)) {
                    //判断状态是否符合
                    String reviewedState = r.getString("reviewedState");
                    if ("0".equals(reviewedState)) {
                        continue;
                    }
                    boolean flag = false;
                    for (int j = 0; j < des.size(); j++) {
                        PrescriptionDiagnosis ds = des.getObject(j, PrescriptionDiagnosis.class);
                        if (gxy.equals(ds.getHealthProblem()) || tnb.equals(ds.getHealthProblem())) {
                            //为糖尿病高血压
                        } else {
                            //如果含有非糖尿病或高血压
                            flag = true;;
                        }
                    }
                    //如果未含有选择的病症,则删除
                    if (flag){
                        continue;
                    }
                }
                //过滤病症
                if(StringUtils.isNotBlank(diagnosisCode)&&!"0".equals(diagnosisCode)){
                    String dis = gxy;
                    if("1".equals(diagnosisCode)){
                        dis = gxy;
                    }else if("2".equals(diagnosisCode)){
                        dis = tnb;
                    }
                    boolean flag = false;
                    for (int j = 0; j < des.size(); j++) {
                        PrescriptionDiagnosis ds = des.getObject(j, PrescriptionDiagnosis.class);
                        //如果含有选择病症,标记为true
                        if (dis.equals(ds.getHealthProblem())) {
                            //含有选择的病症
                            flag = true;
                        }
                    }
                    //如果未含有选择的病症,则删除
                    if (!flag){
                        continue;
                    }
                }
                newtotalCount++;
                filterJsonArray.add(r);
            }
        }
        int limit = newtotalCount>end?end:newtotalCount;
        //分页处理
        com.alibaba.fastjson.JSONArray returnJsonArray = new com.alibaba.fastjson.JSONArray();
        if(newtotalCount>start){
            for (int i = start; i < limit; i++) {
                com.alibaba.fastjson.JSONObject json = filterJsonArray.getJSONObject(i);
                returnJsonArray.add(json);
            }
        }
        returnJson.put("total",newtotalCount);
        returnJson.put("list",returnJsonArray);
        return returnJson;
    }
    /**
     *
     * @param code

+ 193 - 36
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -3,14 +3,18 @@ package com.yihu.wlyy.service.app.scheme;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodPressure;
import com.yihu.wlyy.entity.doctor.scheme.DoctorSchemeBloodSugger;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodPressureVO;
import com.yihu.wlyy.entity.doctor.scheme.vo.DoctorSchemeBloodSuggerVO;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodPressureDao;
import com.yihu.wlyy.repository.doctor.DoctoreSchemeBloodSuggerDao;
import com.yihu.wlyy.repository.doctor.DoctroSchemeBloodSuggerDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.scheme.PatientSchemeListDao;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.lang.StringUtils;
@ -53,6 +57,11 @@ public class DoctorSchemeService {
    @Autowired
    private DoctoreSchemeBloodSuggerDao doctoreSchemeBloodSuggerDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private DevicePatientHealthIndexDao devicePatientHealthIndexDao;
    /**
@ -79,7 +88,7 @@ public class DoctorSchemeService {
            sql = sql + " and p.disease ="+disease;
        }
        if(StringUtils.isNotBlank(diseaseCondition)){
        if(StringUtils.isNotBlank(diseaseCondition) && !"-1".equals(diseaseCondition)){
            sql = sql + " and p.disease_condition IN ("+diseaseCondition +")";
        }
@ -93,6 +102,8 @@ public class DoctorSchemeService {
        }
        sql = sql + " and p.status > 0 and p.disease > 0 ";
        List<String> result = jdbcTemplate.queryForList(sql,new Object[]{},String.class);
@ -115,29 +126,30 @@ public class DoctorSchemeService {
        List<DoctorSchemeBloodSugger> schemelist = doctroSchemeBloodSuggerDao.getListByDoctorcode(doctorcode);
        DoctorSchemeBloodSugger defaultSchemeBloodSugger = doctroSchemeBloodSuggerDao.findByCode("default");
        List<DoctorSchemeBloodSugger> defaultSchemeBloodSugger = doctroSchemeBloodSuggerDao.findByCode("default");
        schemelist.add(defaultSchemeBloodSugger);
        schemelist.addAll(defaultSchemeBloodSugger);
        for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
            if(mapresult.keySet().contains(doctorSchemeBloodSugger.getCode())){
                mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
            }else{
                List<DoctorSchemeBloodSugger> list = new ArrayList<>();
                list.add(doctorSchemeBloodSugger);
                mapresult.put(doctorSchemeBloodSugger.getCode(),list);
        if(!schemelist.isEmpty()){
            for (DoctorSchemeBloodSugger doctorSchemeBloodSugger : schemelist) {
                if(mapresult.keySet().contains(doctorSchemeBloodSugger.getCode())){
                    mapresult.get(doctorSchemeBloodSugger.getCode()).add(doctorSchemeBloodSugger);
                }else{
                    List<DoctorSchemeBloodSugger> list = new ArrayList<>();
                    list.add(doctorSchemeBloodSugger);
                    mapresult.put(doctorSchemeBloodSugger.getCode(),list);
                }
            }
        }
        for (String key :mapresult.keySet()) {
            DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
            doctorSchemeBloodSuggerVO.setCode(key);
            doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
            doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
            doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
            result.add(doctorSchemeBloodSuggerVO);
            for (String key :mapresult.keySet()) {
                DoctorSchemeBloodSuggerVO doctorSchemeBloodSuggerVO = new DoctorSchemeBloodSuggerVO();
                doctorSchemeBloodSuggerVO.setCode(key);
                doctorSchemeBloodSuggerVO.setName(mapresult.get(key).get(0).getName());
                doctorSchemeBloodSuggerVO.setContent(mapresult.get(key).get(0).getContent());
                doctorSchemeBloodSuggerVO.setList(mapresult.get(key));
                result.add(doctorSchemeBloodSuggerVO);
            }
        }
        return result;
    }
@ -155,27 +167,29 @@ public class DoctorSchemeService {
        List<DoctorSchemeBloodPressure> schemelist = doctoreSchemeBloodPressureDao.getListByDoctorcode(doctorcode);
        DoctorSchemeBloodPressure defaultSchemeBloodPressure = doctoreSchemeBloodPressureDao.findByCode("default");
        List<DoctorSchemeBloodPressure> defaultSchemeBloodPressure = doctoreSchemeBloodPressureDao.findByCode("default");
        schemelist.add(defaultSchemeBloodPressure);
        schemelist.addAll(defaultSchemeBloodPressure);
        for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
            if(mapresult.keySet().contains(doctorSchemeBloodPressure.getCode())){
                mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
            }else{
                List<DoctorSchemeBloodPressure> list = new ArrayList<>();
                list.add(doctorSchemeBloodPressure);
                mapresult.put(doctorSchemeBloodPressure.getCode(),list);
        if(!schemelist.isEmpty()){
            for (DoctorSchemeBloodPressure doctorSchemeBloodPressure : schemelist) {
                if(mapresult.keySet().contains(doctorSchemeBloodPressure.getCode())){
                    mapresult.get(doctorSchemeBloodPressure.getCode()).add(doctorSchemeBloodPressure);
                }else{
                    List<DoctorSchemeBloodPressure> list = new ArrayList<>();
                    list.add(doctorSchemeBloodPressure);
                    mapresult.put(doctorSchemeBloodPressure.getCode(),list);
                }
            }
        }
        for (String key :mapresult.keySet()) {
            DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
            doctorSchemeBloodPressureVO.setCode(key);
            doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
            doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
            doctorSchemeBloodPressureVO.setList(mapresult.get(key));
            result.add(doctorSchemeBloodPressureVO);
            for (String key :mapresult.keySet()) {
                DoctorSchemeBloodPressureVO doctorSchemeBloodPressureVO = new DoctorSchemeBloodPressureVO();
                doctorSchemeBloodPressureVO.setCode(key);
                doctorSchemeBloodPressureVO.setName(mapresult.get(key).get(0).getName());
                doctorSchemeBloodPressureVO.setContent(mapresult.get(key).get(0).getContent());
                doctorSchemeBloodPressureVO.setList(mapresult.get(key));
                result.add(doctorSchemeBloodPressureVO);
            }
        }
        return result;
@ -351,4 +365,147 @@ public class DoctorSchemeService {
            }
        }
    }
    /**
     * 医生端-获取慢病管理居民管理端数据
     * @param teamCode
     * @param getcolor
     * @param getstands
     * @param gethealthindex
     * @param startdate
     * @param enddate
     * @return
     */
    public JSONArray getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate) throws Exception{
        List<Patient> patients = patientDao.findAllSignPatientTeamcode(teamCode);
        JSONArray result = new JSONArray();
        JSONObject green = new JSONObject();//绿标
        JSONObject yellow = new JSONObject();//黄标
        JSONObject red = new JSONObject();//红标
        JSONObject pressure_standard =  new JSONObject();//血压预警
        JSONObject sugar_standard =  new JSONObject();//血糖预警
        JSONObject pressure_count =  new JSONObject();//血压体征总数
        JSONObject pressure_unusual_ount =  new JSONObject();//血压体征总数
        JSONObject sugar_count =  new JSONObject();//血糖体征总数
        JSONObject sugar_unusual_count =  new JSONObject();//血糖体征总数
        int count = patients.size();
        //绿标居民
        List<Patient> green_patients = new ArrayList<>();
        //黄标居民
        List<Patient> yellow_patients = new ArrayList<>();
        //红标居民
        List<Patient> red_patients = new ArrayList<>();
        //高血压居民预警居民CODE
        List<String> bloodpressure_patientcodes = new ArrayList<>();
        //高血糖居民预警居民CODE
        List<String> bloodsugar_patientcodes = new ArrayList<>();
        if(!patients.isEmpty()){
            for (Patient patient : red_patients) {
                //获取居民颜色标签
                if(1 == getcolor){
                    switch (patient.getDiseaseCondition()){
                        case 0:
                            green_patients.add(patient);
                            break;
                        case 1:
                            yellow_patients.add(patient);
                            break;
                        case 2:
                            red_patients.add(patient);
                            break;
                    }
                }
                //获取预警居民CODES
                if(1 == getstands && 1 == patient.getStandardStatus()){
                    if( 1 == patient.getDisease() || 3 == patient.getDisease()){
                        bloodpressure_patientcodes.add(patient.getCode());
                    }
                    if( 2 == patient.getDisease() || 3 == patient.getDisease()){
                        bloodsugar_patientcodes.add(patient.getCode());
                    }
                }
            }
        }
        if(1 == getcolor){
            green.put("greencount",green_patients.size());
            yellow.put("yellowcount",yellow_patients.size());
            red.put("redcount",red_patients.size());
            result.add(green);
            result.add(yellow);
            result.add(red);
        }
        if(1 == getstands){
            pressure_standard.put("pressure_standard",bloodpressure_patientcodes);
            sugar_standard.put("sugar_standard",bloodsugar_patientcodes);
            result.add(pressure_standard);
            result.add(sugar_standard);
        }
        if(1 == gethealthindex){
            Date start = DateUtil.strToDate(startdate);
            Date end = DateUtil.strToDate(enddate);
            List<DevicePatientHealthIndex> devicePatientHealthIndices = devicePatientHealthIndexDao.findByTeamcodeAndRecordDate("1,2",start,end,teamCode);
            int sugar = 0;
            int sugar_unusual = 0;
            int pressure = 0;
            int pressure_unusual = 0;
            if(!devicePatientHealthIndices.isEmpty()){
                for (DevicePatientHealthIndex devicePatientHealthIndex : devicePatientHealthIndices) {
                    if( 1 == devicePatientHealthIndex.getType()){
                        sugar++;
                        if( 1 == devicePatientHealthIndex.getStatus()){
                            sugar_unusual++;
                        }
                    }
                    if( 2 == devicePatientHealthIndex.getType()){
                        pressure++;
                        if( 1 == devicePatientHealthIndex.getStatus()){
                            pressure_unusual++;
                        }
                    }
                }
            }
            pressure_count.put("pressure_count",pressure);
            pressure_unusual_ount.put("pressure_unusual_count",pressure_unusual);
            sugar_count.put("sugar_count",sugar);
            sugar_unusual_count.put("sugar_unusual_count",sugar_unusual);
            result.add(pressure_count);
            result.add(pressure_unusual_ount);
            result.add(sugar_count);
            result.add(sugar_unusual_count);
        }
        return result;
    }
}

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

@ -35,7 +35,6 @@ import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.sql.Select;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -344,6 +343,11 @@ public class FamilyContractService extends BaseService {
            services.put(service);
        }
        json.put("services", services);
        //是否签约上限
        int signLimit = signWebService.getSickFamilyDoctorSignLimit(doctor);
        json.put("signLimit", signLimit);
        return json;
    }

+ 48 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -18,6 +18,7 @@ import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
@ -30,6 +31,7 @@ import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.jw.JwSignService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -37,6 +39,8 @@ import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -55,6 +59,7 @@ import java.util.*;
@Component
@Transactional
public class SignWebService extends BaseService {
    private static Logger logger = LoggerFactory.getLogger(SignWebService.class);
    @Autowired
    private SignWebDao signWebDao;
@ -98,7 +103,10 @@ public class SignWebService extends BaseService {
    private SignFamilyServerDao signFamilyServerDao;
    @Autowired
    private ChargeDao chargeDao;
    @Autowired
    private JwSignService jwSignService;
    @Autowired
    private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
    @Autowired
    private TownDao townDao;
    @Autowired
@ -2606,4 +2614,43 @@ public class SignWebService extends BaseService {
        json.put("signFamilyServer",ja);
        return json;
    }
    /**
     * 判断医生所属行政团队是否已达上限
     * @param doctorCode
     * @return
     */
    public Integer getSickFamilyDoctorSignLimit(String doctorCode){
        Integer re = 0;//0未达上线 1 已达上限
        List<AdminTeam> adminTeams = doctorAdminTeamMemberDao.findDoctorTeams(doctorCode);
        int limitNum = 0;
        for(AdminTeam one:adminTeams){
            //获取团队签约数
            Integer signCount = signFamilyDao.findByAdminTeamIdAndStatus(one.getId(),0);
            //获取智业团队签约上线
            String jwCode = one.getMappingCode();//智业服务团队的code
            try{
                String response = jwSignService.getSickFamilyDoctorSignLimit(jwCode);
                com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(response);
                if(json.getInteger("status")==200){
                    com.alibaba.fastjson.JSONObject data = json.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        int sign_limit_number = data.getJSONArray("DATA").getJSONObject(0).getInteger("SIGN_LIMIT_NUMBER");//签约上线
                        if(signCount>=sign_limit_number){
                            limitNum++;
                        }
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if(adminTeams.size()==limitNum){
            re = 1;
        }
        return re;
    }
}

+ 43 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -16,6 +16,7 @@ import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.JwSignService;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
@ -47,7 +48,8 @@ public class AdminTeamService extends BaseService {
    @Autowired
    DoctorAdminTeamMemberDao memberDao;
    @Autowired
    private JwSignService jwSignService;
    @Autowired
    DoctorTeamMemberDao signingTeamMemberDao;
@ -235,6 +237,46 @@ public class AdminTeamService extends BaseService {
        return memberDao.findDoctorTeams(doctorCode);
    }
    /**
     * 获取行政团队
     * @param doctorCode
     * @return
     */
    public com.alibaba.fastjson.JSONArray getAdminTeams(String doctorCode){
        List<AdminTeam> adminTeams = memberDao.findDoctorTeams(doctorCode);
        com.alibaba.fastjson.JSONArray re = new com.alibaba.fastjson.JSONArray();
        for(AdminTeam one:adminTeams){
            //获取团队签约数
            Integer signCount = signFamilyDao.findByAdminTeamIdAndStatus(one.getId(),0);
            //获取智业团队签约上线
            String jwCode = one.getMappingCode();//智业服务团队的code
            int sign_limit_number = 0;
            try{
                String response = jwSignService.getSickFamilyDoctorSignLimit(jwCode);
                com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(response);
                if(json.getInteger("status")==200){
                    com.alibaba.fastjson.JSONObject data = json.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        sign_limit_number = data.getJSONArray("DATA").getJSONObject(0).getInteger("SIGN_LIMIT_NUMBER");//签约上线
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
            json.put("id",one.getId());
            json.put("name",one.getName());
            json.put("createTime",one.getCreateTime());
            json.put("leaderCode",one.getLeaderCode());
            json.put("available",one.isAvailable());
            json.put("orgCode",one.getOrgCode());
            json.put("signCount",signCount);
            json.put("signLimitNumber",sign_limit_number);
            re.add(json);
        }
        return re;
    }
    /**
     * 添加成员。
     *

+ 8 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -808,8 +808,13 @@ public class PatientService extends TokenService {
                "    f.`code` " +
                "   FROM " +
                "    wlyy_sign_family f " ;
        if(isSlowDisease){
            totalGSql = totalGSql + " ,wlyy_patient p WHERE f.patient = p.code AND p.disease >0 AND p.status > 0 ";
        }
        if(StringUtils.isNotBlank(diseaseCondition)){
            totalGSql = totalGSql + " ,wlyy_patient p WHERE f.patient = p.code AND p.disease_condition = "+diseaseCondition +" AND ";
            totalGSql = totalGSql + " AND p.disease_condition = "+diseaseCondition +" AND ";
        }else{
            totalGSql = totalGSql + " WHERE ";
        }
@ -830,7 +835,7 @@ public class PatientService extends TokenService {
                " d.`year` = '" + DateUtil.getSignYear() + "' " ;
        if(isSlowDisease){
            //获取预警分组数量
            totalGSql = totalGSql +"  AND d. CODE in (4,5)  ";
//            totalGSql = totalGSql +"  AND d. CODE in (4,5)  ";
        }
        totalGSql = totalGSql +
@ -886,7 +891,7 @@ public class PatientService extends TokenService {
        if(isSlowDisease){
            //获取预警分组数量
            fousGSql = fousGSql +"  AND d. CODE in (4,5)  ";
//            fousGSql = fousGSql +"  AND d. CODE in (4,5)  ";
        }
        fousGSql = fousGSql +

+ 114 - 57
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -3,8 +3,11 @@ package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
@ -17,9 +20,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 基位长处方接口
@ -40,6 +41,10 @@ public class JwPrescriptionService {
    private PrescriptionDao prescriptionDao;
    @Value("${spring.profiles}")
    private String profiles;
    @Autowired
    private Icd10DictServcie icd10DictServcie;
    @Autowired
    private ZyDictService zyDictService;
    /**
     * 获取字典列表
@ -75,7 +80,7 @@ public class JwPrescriptionService {
    /**
     * 获取历史处方记录列表
     * 获取历史处方记录
     * @param cardNo 社保卡号
     * @param recipeNo 医嘱号
     * @param applyTimeFrom 开始时间
@ -91,75 +96,127 @@ public class JwPrescriptionService {
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
        String response = "";
        if("prod".equals(profiles)){
            response = httpClientUtil.post(url, params, "UTF-8");
        }else {
            String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
            List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
            response = list.get(0).get("response").toString();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("status",200);
            jsonObject.put("data",response);
            response = jsonObject.toString();
        }
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * 获取处方列表
     * @param cardNo
     * @param recipeNo
     * @param patientCode
     * @param applyTimeFrom
     * @param applyTimeEnd
     * @return
     */
    public String getRecipeList(String cardNo,String recipeNo,String applyTimeFrom,String applyTimeEnd){
        JSONObject recipeJson = new JSONObject();
        try{
            Map<String,String> map = new HashMap<>();
            JSONArray jsonArray = new JSONArray();
            for (int i=0;i<3;i++){
                if(!map.containsKey(recipeNo)){
                    map.put(recipeNo,recipeNo);
                    String response = getLastRecipe(cardNo,recipeNo,applyTimeFrom,applyTimeEnd);
                    JSONObject json = JSONObject.parseObject(response);
                    if(json.getInteger("status")==200){
                        //智业接口每次返回一条数据,需要遍历请求
                        JSONObject data = json.getJSONObject("data");
                        String code = data.getString("CODE");
                        if("1".equals(code)){
                            JSONArray returnData = data.getJSONArray("returnData");
                            if(returnData.size()>0){
                                JSONObject recipe = returnData.getJSONArray(0).getJSONObject(0);//获取最后一条处方
                                jsonArray.add(recipe);
                                recipeNo = recipe.getString("RECIPE_NO");
                                if(recipeJson.isEmpty()){
                                    recipeJson = json;
                                }else {
                                    recipeJson.getJSONObject("data").getJSONArray("returnData").getJSONArray(0).add(recipe);
                                }
                            }
    public JSONObject getRecipeMasterList(String patientCode,String applyTimeFrom,String applyTimeEnd) throws Exception{
        JSONObject re = new JSONObject();
        String url = jwUrl + "/third/prescription/getRecipeMasterList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("patientCode", patientCode));
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
        JSONArray jsonArray = new JSONArray();
        Integer totalCount = 0;
        String errorMsg = "";
        String response = httpClientUtil.post(url, params, "UTF-8");
//        String sql = "SELECT h.response from wlyy_zy_push_log h WHERE h.id = 436";
//        List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
//        String response = list.get(0).get("response").toString();
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("status",200);
//        jsonObject.put("data",response);
//        response = jsonObject.toString();
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            //智业接口,需要遍历请求 实现分页
            JSONObject data = json.getJSONObject("data");
            String code = data.getString("CODE");
            if("1".equals(code)){
                JSONArray returnData = data.getJSONArray("returnData");
                JSONArray byRefParaData = data.getJSONArray("byRefParaData");
                totalCount = byRefParaData.getJSONObject(0).getInteger("totalCount");
                errorMsg = byRefParaData.getJSONObject(0).getString("errorMsg");
                if(returnData.size()>0){
                    for(int i=0;i<totalCount;i++){
                        JSONObject recipe = returnData.getJSONArray(0).getJSONObject(i);//获取最后一条处方
                        JSONObject pre = new JSONObject();
                        pre.put("code",recipe.getString("RECIPE_NO"));//医嘱号
                        pre.put("createTime",recipe.getString("APPLY_TIME"));//开单时间
//                        pre.put("applyOperator",recipe.getString("APPLY_OPERATOR"));//开单医生代码
//                        pre.put("applyOperatorName",recipe.getString("APPLY_OPERATOR_NAME"));//开单医生姓名
//                        pre.put("healthOrgCode",recipe.getString("HEALTH_ORG_CODE"));//开单机构编码
                        //开方医生和医院
                        Doctor doctor =  zyDictService.getDoctByJw(recipe.getString("APPLY_OPERATOR"),recipe.getString("HEALTH_ORG_CODE"));
                        // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                        if(doctor!=null){
                            pre.put("doctor",doctor.getCode());
                            pre.put("doctorName",doctor.getName());
                            pre.put("hospitalName",doctor.getHospitalName());
                            pre.put("hospital",doctor.getHospital());
                        }else{
                            pre.put("doctor",recipe.getString("APPLY_OPERATOR"));
                            pre.put("doctorName",recipe.getString("APPLY_OPERATOR_NAME"));
                            pre.put("hospitalName",recipe.getString("HEALTH_ORG_CODE"));
                            pre.put("hospital",recipe.getString("HEALTH_ORG_CODE"));
                        }
                        pre.put("prescriptionDt",getDiagnosis(recipe));
                        jsonArray.add(pre);
                    }
                }
            }
            if(jsonArray.size()>1){
                JSONObject re = new JSONObject();
                re.put("status",200);
                re.put("msg","调阅历史处方接口!");
                JSONObject data = new JSONObject();
                data.put("CODE","1");
                JSONArray returnData = new JSONArray();
                returnData.add(jsonArray);
                data.put("returnData",returnData);
                re.put("data",data);
                return re.toString();
        }
        re.put("list",jsonArray);
        re.put("totalCount",totalCount);
        re.put("errorMsg",errorMsg);
        return re;
    }
    /**
     * 诊断类型转换
     * @param recipe
     * @return
     */
    private JSONArray getDiagnosis(JSONObject recipe){
        JSONArray jsonArrayDt = new JSONArray();
        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
        String diagnoseCode = recipe.getString("DIAGNOSE_CODE");//诊断代码
        String diagnoseName = recipe.getString("DIAGNOSE_NAME");//诊断名称
        diagnosis.setCode(diagnoseCode);//诊断代码
        diagnosis.setName(diagnoseName);//诊断名称
        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
        if(!StringUtils.isEmpty(icd10)){
            JSONObject icd = JSONObject.parseObject(icd10);
            diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
            diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
        }else{
            diagnosis.setHealthProblemName(diagnoseName);//诊断名称
            diagnosis.setHealthProblem(diagnoseCode);//诊断代码
        }
        jsonArrayDt.add(diagnosis);
        if(recipe.getString("DIAGNOSE_SUB_CODE")!=null){
            diagnosis = new PrescriptionDiagnosis();
            diagnoseCode = recipe.getString("DIAGNOSE_SUB_CODE");
            diagnoseName = recipe.getString("DIAGNOSE_SUB_NAME");
            diagnosis.setCode(diagnoseCode);//次诊断代码
            diagnosis.setName(diagnoseName);//次诊断名称
            icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
            if(!StringUtils.isEmpty(icd10)){
                JSONObject icd = JSONObject.parseObject(icd10);
                diagnosis.setHealthProblemName(icd.getString("value"));//次诊断名称
                diagnosis.setHealthProblem(icd.getString("key"));//次诊断代码
            }else{
                diagnosis.setHealthProblemName(diagnoseName);//次诊断名称
                diagnosis.setHealthProblem(diagnoseCode);//次诊断代码
            }
        }catch (Exception e){
            e.printStackTrace();
            jsonArrayDt.add(diagnosis);
        }
        return recipeJson.toString();
        return jsonArrayDt;
    }
    /**

+ 14 - 11
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSignService.java

@ -1,25 +1,14 @@
package com.yihu.wlyy.service.third.jw;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.ehr.EhrService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/12/19.
@ -74,4 +63,18 @@ public class JwSignService {
        return HttpClientUtil.post(url, params, "UTF-8");
    }
    /**
     * 获取医生团队的签约上线
     * @param jwTeamCode
     * @return
     */
    public String getSickFamilyDoctorSignLimit(String jwTeamCode){
        String url = jwUrl + "/third/sign/getSickFamilyDoctorSignLimit";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("jwTeamCode", jwTeamCode));
        return HttpClientUtil.post(url, params, "UTF-8");
    }
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -90,6 +90,7 @@ public class LoginController extends BaseController {
                return write(200, "公钥获取成功!", "data", json);
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "公钥获取失败!");
        }
    }

+ 11 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -208,8 +208,12 @@ public class DoctorHealthController extends BaseController {
				return error(-1, "保存失败!");
			}
			if(patient.contains(",")){
				String[] pcodeArray = patient.split(",");
				String[] pcodeArray = new String[1];
				if(patient.contains(",")){
					pcodeArray = patient.split(",");
				}else{
					pcodeArray = new String[]{patient};
				}
				if(pcodeArray != null && pcodeArray.length > 0){
					// 生成数据对象
					List<PatientHealthStandard> list = new ArrayList<>();
@ -262,7 +266,6 @@ public class DoctorHealthController extends BaseController {
					}
				}
			}
			return write(200, "保存成功");
		} catch (Exception e) {
@ -365,15 +368,15 @@ public class DoctorHealthController extends BaseController {
						continue;
					}
					JSONObject json = new JSONObject();
					// 最低安全值(血糖餐前\收缩压\体重\腰围)
					// 最低安全值(血糖餐前\收缩压\体重\腰围\BMI)
					json.put("min_value_1", phs.getMinValue1());
					// 最高安全值(血糖餐前\收缩压\体重\腰围)
					// 最高安全值(血糖餐前\收缩压\体重\腰围\BMI)
					json.put("max_value_1", phs.getMaxValue1());
					// 最低安全值(血糖餐后\舒张压)
					// 最低安全值(血糖餐后\舒张压\步数)
					json.put("min_value_2", phs.getMinValue2());
					// 最高安全值(血糖餐后\舒张压)
					// 最高安全值(血糖餐后\舒张压\步数)
					json.put("max_value_2", phs.getMaxValue2());
					// 健康指标类型:1血糖,2血压,3体重,4腰围
					// 健康指标类型:1血糖,2血压,3BMI,4腰围
					json.put("type", phs.getType());
					userArray.put(json);
				}

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

@ -96,7 +96,7 @@ public class PatientInfoController extends BaseController {
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient,brithday, jwCountryCode, nation, blood, marry,adress));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取患者信息失败!");
            return invalidUserException(e, -1, "档案建立失败!");
        }
    }

+ 25 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -2,12 +2,14 @@ package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.scheme.DoctorSchemeService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -32,6 +34,8 @@ public class SignPatientLabelInfoController extends BaseController {
    SignWebService signWebService;
    @Autowired
    PatientService patientService;
    @Autowired
    private DoctorSchemeService doctorSchemeService;
    /**
@ -830,4 +834,25 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value="/slowdisease/get/teaminfos",method = RequestMethod.GET)
    @ApiOperation("医生端-获取慢病管理居民管理端数据")
    public String getDiseasePatientCodes (
            @ApiParam(name="teamCode", value="团队CODE") @RequestParam(value = "teamCode",required = true,defaultValue = "642") String teamCode,
            @ApiParam(name="getcolor", value="是否获取颜色标签") @RequestParam(value = "getcolor",required = true,defaultValue = "1")  int getcolor,
            @ApiParam(name="getstands", value="是否获取预警人数数据") @RequestParam(value = "getstands",required = true,defaultValue = "1")  int getstands,
            @ApiParam(name="gethealthindex", value="是否获取体征数据") @RequestParam(value = "gethealthindex",required = true,defaultValue = "1")  int gethealthindex,
            @ApiParam(name="startdate", value="体征数据开始时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "startdate",required = false,defaultValue = "")  String startdate,
            @ApiParam(name="enddate", value="体征数据结束时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "enddate",required = false,defaultValue = "")  String enddate){
        try {
            com.alibaba.fastjson.JSONArray result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate);
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "查询失败,"+e.getMessage());
        }
    }
}

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -265,9 +265,9 @@ public class AdminTeamController extends BaseController {
    @ApiOperation(value = "获取医生团队列表")
    public String getDoctorTeams(@PathVariable("doctor_code") String doctorCode) {
        try {
            List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
            return write(200, "OK", "data", new JSONArray(teamList));
//            List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
//            return write(200, "OK", "data", new JSONArray(teamList));
            return write(200, "OK", "data", teamService.getAdminTeams(doctorCode));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());

+ 63 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.patient.account;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
@ -21,6 +22,7 @@ import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -918,4 +920,65 @@ public class PatientController extends WeixinBaseController {
            return error(-1, "切换账号失败");
        }
    }
    @RequestMapping(value = "createProfile",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("档案建立")
    @ObserverRequired
    public String createProfile(@ApiParam(value = "医生code", name = "doctorCode") @RequestParam(required = true)String doctorCode ,
                                @ApiParam(value = "患者code", name = "patient") @RequestParam(required = true)String patient,
                                @ApiParam(value = "生日(yyyy-MM-dd)", name = "brithday") @RequestParam(required = true)String brithday,
                                @ApiParam(value = "居委会", name = "jwCountryCode") @RequestParam(required = true)String jwCountryCode,
                                @ApiParam(value = "民族", name = "nation") @RequestParam(required = true)String nation,
                                @ApiParam(value = "血型", name = "blood") @RequestParam(required = true)String blood,
                                @ApiParam(value = "婚姻状况", name = "marry") @RequestParam(required = true)String marry,
                                @ApiParam(value = "详细地址", name = "adress") @RequestParam(required = true)String adress){
        try {
            // 获取医生下的患者
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient,brithday, jwCountryCode, nation, blood, marry,adress));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "档案建立失败!");
        }
    }
    @RequestMapping(value = "getNationDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取民族信息列表")
    public String getNationDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getNationDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getMarryDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("婚姻状态字典")
    public String getMarryDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getMarryDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getBloodDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("血型状态字典")
    public String getBloodDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getBloodDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

@ -55,6 +55,25 @@ public class PatientPrescriptionInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "getRecipeMasterList" , method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取智业长处方信息列表")
    public String getRecipeMasterList(@RequestParam(required = false)@ApiParam(name="isRenewal",value="处方是否可续方:1.是;2.无过滤")String isRenewal,
                                      @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                      @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                      @RequestParam(required = false,defaultValue = "0")@ApiParam(name="diagnosisCode",value="所有诊断(0 全部 1高血压 2糖尿病)")String diagnosisCode,
                                      @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                      @RequestParam(required = false)@ApiParam(name="size",value="每页记录数")Integer size){
        try {
//            com.alibaba.fastjson.JSONObject json = prescriptionInfoService.getRecipeMasterList("ec7572875d27446cb4f067b13a85d72a",startDate,endDate,isRenewal,diagnosisCode,page,size);
            com.alibaba.fastjson.JSONObject json = prescriptionInfoService.getRecipeMasterList(getRepUID(),startDate,endDate,isRenewal,diagnosisCode,page,size);
            return write(200, "查询成功!", "data",json);
        }catch (Exception e){
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPrescription" ,method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取长处方详细信息")