Преглед изворни кода

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

trick9191 пре 7 година
родитељ
комит
f7f7a09a45
17 измењених фајлова са 999 додато и 82 уклоњено
  1. 24 15
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/ServerLabelTree.java
  2. 42 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java
  3. 41 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyMapping.java
  4. 51 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyRenew.java
  5. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  6. 5 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java
  7. 11 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewLogDao.java
  8. 236 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  9. 83 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  10. 261 28
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  11. 23 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  12. 131 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  13. 8 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  14. 9 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  15. 7 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  16. 61 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  17. 3 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

+ 24 - 15
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/ServerLabelTree.java

@ -7,25 +7,26 @@ import java.util.List;
 */
public class ServerLabelTree {
    private String type;
    private String code;
    private String name;
    private Long amount;
    private String labelCode;
    private String labelName;
    private Long focusAmount;
    private List<ServerLabelTree> ch;
    public String getType() {
        return type;
    public Long getAmount() {
        return amount;
    }
    public void setType(String type) {
        this.type = type;
    public void setAmount(Long amount) {
        this.amount = amount;
    }
    public String getCode() {
        return code;
    public Long getFocusAmount() {
        return focusAmount;
    }
    public void setCode(String code) {
        this.code = code;
    public void setFocusAmount(Long focusAmount) {
        this.focusAmount = focusAmount;
    }
    public List<ServerLabelTree> getCh() {
@ -36,11 +37,19 @@ public class ServerLabelTree {
        this.ch = ch;
    }
    public String getName() {
        return name;
    public String getLabelName() {
        return labelName;
    }
    public void setName(String name) {
        this.name = name;
    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }
    public String getLabelCode() {
        return labelCode;
    }
    public void setLabelCode(String labelCode) {
        this.labelCode = labelCode;
    }
}

+ 42 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java

@ -64,6 +64,48 @@ public class SignFamily extends IdEntity {
    private Long adminTeamId;//行政团队ID
    private Date expensesTime;//缴费时间
    //1.3.3.2新增字段
    //基卫服务类型
    private String serverType;
    //基卫服务类型名称
    private String serverTypeName;
    //基卫特殊人群类别
    private String specialPopulation;
    //基卫特殊人群类别名称
    private String specialPopulationName;
    public String getServerType() {
        return serverType;
    }
    public void setServerType(String serverType) {
        this.serverType = serverType;
    }
    public String getServerTypeName() {
        return serverTypeName;
    }
    public void setServerTypeName(String serverTypeName) {
        this.serverTypeName = serverTypeName;
    }
    public String getSpecialPopulation() {
        return specialPopulation;
    }
    public void setSpecialPopulation(String specialPopulation) {
        this.specialPopulation = specialPopulation;
    }
    public String getSpecialPopulationName() {
        return specialPopulationName;
    }
    public void setSpecialPopulationName(String specialPopulationName) {
        this.specialPopulationName = specialPopulationName;
    }
    public String getCode() {
        return code;
    }

+ 41 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyMapping.java

@ -33,6 +33,47 @@ public class SignFamilyMapping extends IdEntity {
	// 上传时间
	private Date uploadTime;
	//签约年度
	private String SignYear;
	//是否需要上传预签
	private String needRenewUpload;
	//上传预签时间
	private Date renewUploadTime;
	//基卫续签ID
	private String renewProId;
	public String getSignYear() {
		return SignYear;
	}
	public void setSignYear(String signYear) {
		SignYear = signYear;
	}
	public String getNeedRenewUpload() {
		return needRenewUpload;
	}
	public void setNeedRenewUpload(String needRenewUpload) {
		this.needRenewUpload = needRenewUpload;
	}
	public Date getRenewUploadTime() {
		return renewUploadTime;
	}
	public void setRenewUploadTime(Date renewUploadTime) {
		this.renewUploadTime = renewUploadTime;
	}
	public String getRenewProId() {
		return renewProId;
	}
	public void setRenewProId(String renewProId) {
		this.renewProId = renewProId;
	}
	public String getCode() {
		return code;
	}

+ 51 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyRenew.java

@ -63,6 +63,57 @@ public class SignFamilyRenew extends IdEntity {
    private Long adminTeamId;//行政团队ID
    private Date expensesTime;//缴费时间
    private Integer isValid;//是否生效
    private String renewFlag;//1 医生续签 2 医生改签续签
    //1.3.3.2新增字段
    //基卫服务类型
    private String serverType;
    //基卫服务类型名称
    private String serverTypeName;
    //基卫特殊人群类别
    private String specialPopulation;
    //基卫特殊人群类别名称
    private String specialPopulationName;
    public String getRenewFlag() {
        return renewFlag;
    }
    public void setRenewFlag(String renewFlag) {
        this.renewFlag = renewFlag;
    }
    public String getServerType() {
        return serverType;
    }
    public void setServerType(String serverType) {
        this.serverType = serverType;
    }
    public String getServerTypeName() {
        return serverTypeName;
    }
    public void setServerTypeName(String serverTypeName) {
        this.serverTypeName = serverTypeName;
    }
    public String getSpecialPopulation() {
        return specialPopulation;
    }
    public void setSpecialPopulation(String specialPopulation) {
        this.specialPopulation = specialPopulation;
    }
    public String getSpecialPopulationName() {
        return specialPopulationName;
    }
    public void setSpecialPopulationName(String specialPopulationName) {
        this.specialPopulationName = specialPopulationName;
    }
    public String getCode() {
        return code;

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

@ -8,6 +8,7 @@ package com.yihu.wlyy.repository.patient;
import java.util.List;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
@ -389,4 +390,6 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select count(1) from SignFamily f where f.status > 0 and f.patient = ?1 and ( f.doctor = ?2 or doctorHealth = ?2  )")
    int findByPatientAndDoctor(String patient, String doctor);
    @Query(value = "select a from SignFamily a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status >= 0")
    List<SignFamily> findByDoctorAndPatientHossPost(String doctor, String patient, String signYear);
}

+ 5 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java

@ -30,8 +30,8 @@ public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamil
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 ")
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 0")
    List<SignFamilyRenew> findByDoctorAndPatientStatus0(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status >= 0")
    List<SignFamilyRenew> findByDoctorAndPatientHossPost(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamilyRenew> findByDoctorAndPatientIsValid(String doctor,String patient,String signYear);
@ -53,4 +53,7 @@ public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamil
    List<SignFamilyRenew> findByTeamCodeIsValid(String teamCode,String code);
    SignFamilyRenew findByCode(String code);
    @Query("select a from SignFamilyRenew a where a.patient = ?1 and a.type = ?2 and a.status > 0")
    SignFamilyRenew findSignByPatient(String patient, int type);
}

+ 11 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewLogDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.SignFamilyRenewLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/6/13.
 */
public interface SignFamilyRenewLogDao  extends PagingAndSortingRepository<SignFamilyRenewLog, Long>, JpaSpecificationExecutor<SignFamilyRenewLog> {
}

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

@ -174,6 +174,12 @@ public class SignPatientLabelInfoService extends BaseService {
            json.put("jtAdminTeam", familySign.getAdminTeamId());
            json.put("jtHospital", familySign.getHospital());
            json.put("jtHospitalName", familySign.getHospitalName());
            if(StringUtils.isNotBlank(familySign.getSpecialPopulation())){
                json.put("jtServerName", familySign.getSpecialPopulationName()==null?"":familySign.getSpecialPopulationName());
            }else{
                json.put("jtServerName", familySign.getServerTypeName()==null?"":familySign.getServerTypeName());
            }
            if ("1".equals(familySign.getExpensesStatus())) {
                json.put("qyrq", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD) : "");
@ -943,6 +949,234 @@ public class SignPatientLabelInfoService extends BaseService {
    }
    /**
     * 续签设置标签v1.3.3.2
     * 设置患者标签
     *
     * @param patient     患者名称
     * @param health      健康情况标签
     * @param disease     疾病类型标签
     * @param custom      自定义标签
     * @return
     */
    public int setRenewPatientLabels(String patient, String health, String disease, String custom, String doctor, String caller) {
        Patient p = patientDao.findByCode(patient);
        String idcard;
        String patientName;
        if (p == null) {
            return 0;
        } else {
            idcard = p.getIdcard();
            patientName = p.getName();
            List<PatientDisease> diseaseSs = diseaseDao.findByPatientSsDisease(p.getCode());
            if (diseaseSs != null && diseaseSs.size() > 0) {
                String[] diseaseArr = disease.split(",");
                if (diseaseArr == null || diseaseArr.length < 1) {
                    return -3;
                }
                for (PatientDisease dis : diseaseSs) {
                    if (!Arrays.asList(diseaseArr).contains(dis.getDisease())) {
                        return -3;
                    }
                }
            }
        }
        JSONArray logArray = new JSONArray();
        JSONArray teams = adminTeamService.findRenewPatientDoctorTeam(patient, doctor);
        List<String> teamCodes = new ArrayList<>();
        if (teams.length() > 0) {
            for (int i = 0; i < teams.length(); i++) {
                teamCodes.add(String.valueOf(teams.getJSONObject(i).getLong("id")));
            }
        } else {
            return -4;
        }
        String[] diseaseArr = disease.split(",");
        String[] customArr = custom.split(",");
        if (StringUtils.isNotEmpty(health)) {
            SignPatientLabelInfo healthEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, health, "2", 1);
            if (healthEx == null) {
                // 健康情况标签
                int healthAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "2", 1);
                SignPatientLabelInfo healthLabel = new SignPatientLabelInfo();
                SignPatientLabel label = labelService.getLabelByCodeAndType(health, "2");
                if (label == null) {
                    return -1;
                }
                healthLabel.setPatient(patient);
                healthLabel.setPname(patientName);
                healthLabel.setLabelType("2");
                healthLabel.setLabel(health);
                healthLabel.setLabelName(label.getLabelName());
                healthLabel.setStatus(1);
                healthLabel.setCzrq(new Date());
                labelInfoDao.save(healthLabel);
                logArray.put(new JSONObject(label));
            }
        } else {
            return -2;
        }
        if (diseaseArr != null && diseaseArr.length > 0) {
            List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, "3", 1);
            Map<String, SignPatientLabelInfo> labelMap = new HashMap<>();
            List<String> disList = Arrays.asList(diseaseArr);
            for (SignPatientLabelInfo label : labels) {
                labelMap.put(label.getLabel(), label);
                if (!disList.contains(label.getLabel())) {
                    label.setStatus(0);
                    labelInfoDao.save(label);
                }
            }
            for (String diseaseLabel : diseaseArr) {
                if (StringUtils.isEmpty(diseaseLabel)) {
                    continue;
                }
                SignPatientLabelInfo diseaseEx = labelMap.get(diseaseLabel);
                if (diseaseEx == null) {
                    SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
                    SignPatientLabel label = labelService.getLabelByCodeAndType(diseaseLabel, "3");
                    if (label == null) {
                        return -1;
                    }
                    disLabel.setPatient(patient);
                    disLabel.setPname(patientName);
                    disLabel.setLabelType("3");
                    disLabel.setLabel(diseaseLabel);
                    disLabel.setLabelName(label.getLabelName());
                    disLabel.setStatus(1);
                    disLabel.setCzrq(new Date());
                    labelInfoDao.save(disLabel);
                    logArray.put(new JSONObject(label));
                }
            }
        } else {
            // 疾病类型标签
            int disAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "3", 1);
        }
        List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, "4", 1);
        Map<String, SignPatientLabelInfo> labelMap = new HashMap<>();
        List<String> custList = Arrays.asList(customArr);
        for (SignPatientLabelInfo label : labels) {
            labelMap.put(label.getLabel(), label);
            SignPatientLabel lb = labelService.getLabelByCodeAndType(label.getLabel(), "4");
            if (!custList.contains(label.getLabel())) {
                if (lb.getLabelCode().equals("1") || lb.getLabelCode().equals("2") || teamCodes.contains(String.valueOf(lb.getTeamCode()))) {
                    label.setStatus(0);
                    labelInfoDao.save(label);
                }
            }
        }
        if (customArr != null && customArr.length > 0) {
            for (String customLabel : customArr) {
                if (StringUtils.isEmpty(customLabel)) {
                    continue;
                }
                SignPatientLabelInfo customEx = labelMap.get(customLabel);
                if (customEx == null) {
                    SignPatientLabelInfo cusLabel = new SignPatientLabelInfo();
                    SignPatientLabel label = labelService.getLabelByCodeAndType(customLabel, "4");
                    if (label == null) {
                        return -1;
                    }
                    cusLabel.setPatient(patient);
                    cusLabel.setPname(patientName);
                    cusLabel.setLabelType("4");
                    cusLabel.setLabel(customLabel);
                    cusLabel.setLabelName(label.getLabelName());
                    cusLabel.setStatus(1);
                    cusLabel.setCzrq(new Date());
                    labelInfoDao.save(cusLabel);
                    logArray.put(new JSONObject(label));
                }
            }
        }
        if (diseaseArr != null && diseaseArr.length > 0 && (Arrays.asList(diseaseArr).contains("1")
                || Arrays.asList(diseaseArr).contains("2"))) {
            SignPatientLabelInfo mbEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, "2", "1", 1);
            if (mbEx == null) {
                // 卫计委三大分组
                int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
                SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
                disLabel.setPatient(patient);
                disLabel.setPname(patientName);
                disLabel.setLabelType("1");
                disLabel.setLabel("2");
                disLabel.setLabelName("慢病人群");
                disLabel.setStatus(1);
                disLabel.setCzrq(new Date());
                labelInfoDao.save(disLabel);
                logArray.put(new JSONObject("{\"labelCode\":\"1\",\"labelName\":\"慢病人群\",\"labelType\":\"1\"}"));
            }
        } else {
            int age = IdCardUtil.getAgeForIdcard(idcard);
            String lbCode = "", lbName = "";
            if (age >= 65) {
                lbCode = "3";
                lbName = "65岁以上人群";
            } else {
                lbCode = "1";
                lbName = "普通人群";
            }
            SignPatientLabelInfo wjwEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, lbCode, "1", 1);
            if (wjwEx == null) {
                // 卫计委三大分组
                int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
                SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
                disLabel.setPatient(patient);
                disLabel.setPname(patientName);
                disLabel.setLabelType("1");
                disLabel.setStatus(1);
                disLabel.setCzrq(new Date());
                disLabel.setLabel(lbCode);
                disLabel.setLabelName(lbName);
                labelInfoDao.save(disLabel);
                logArray.put(new JSONObject("{\"labelCode\":\"" + lbCode + "\",\"labelName\":\"" + lbName + "\",\"labelType\":\"1\"}"));
            }
        }
        BusinessLogs.info(BusinessLogs.BusinessType.label, caller, patient, logArray);
        return 1;
    }
    /**
     * 设置患者标签
     *
@ -1238,10 +1472,10 @@ public class SignPatientLabelInfoService extends BaseService {
                        // 是否为签约团队标签
                        boolean teamLabelFlag = false;
                        if (ssTeam > 0 && ssTeam == lb.getTeamCode()) {
                        if (ssTeam > 0 && ssTeam == (lb.getTeamCode()==null?0:lb.getTeamCode())) {
                            teamLabelFlag = true;
                        }
                        if (jtTeam > 0 && jtTeam == lb.getTeamCode()) {
                        if (jtTeam > 0 && jtTeam == (lb.getTeamCode()==null?0:lb.getTeamCode())) {
                            teamLabelFlag = true;
                        }
                        // 有签约关系时,判断标签是否在签约团队标签,不是签约团队标签不显示;无签约关系时返回全部

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

@ -101,8 +101,8 @@ public class FamilyContractService extends BaseService {
    MessageService messageService;
    @Autowired
    AdminTeamService adminTeamService;
    @Autowired
    SignWebService signWebService;
    @Autowired
    SignPatientLabelDao labelDao;
@ -124,6 +124,9 @@ public class FamilyContractService extends BaseService {
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
    @Autowired
    private SignFamilyMappingDao signFamilyMappingDao;
    public SignFamily findSignFamilyByCode(String code) {
        return signFamilyDao.findByCodeAndType(code, 2);
    }
@ -816,7 +819,7 @@ public class FamilyContractService extends BaseService {
                                         String emerMobile, String images,
                                         String healthLabel, String customLabel, String disease,
                                         String expenses, String signDoctorCode,
                                         String signDoctorName, String signDoctorLevel, long adminTeamCode) throws Exception {
                                         String signDoctorName, String signDoctorLevel, long adminTeamCode,String sevId) throws Exception {
        // 查询是否有家庭签约
        SignFamily sc = signFamilyDao.findByIdcard(idcard);
        if (sc != null) {
@ -890,6 +893,10 @@ public class FamilyContractService extends BaseService {
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        //设置1.3.3.2服务信息
        if(StringUtils.isNotBlank(sevId)){
            signWebService.setSevId(sf,sevId);
        }
        // 查询该患者是否已注册
        Patient patient = patientDao.findByIdcard(idcard);
        if (patient == null) {
@ -1004,6 +1011,10 @@ public class FamilyContractService extends BaseService {
        }
        SignFamily temp = signFamilyDao.save(sf);
        //设置基卫标识1.3.3.2版本更新
        setSignFamilyMapping(temp.getIdcard(),temp.getSignYear());
        if (temp != null && patient != null) {
            Doctor doc = doctorDao.findByCode(sf.getDoctor());
            Hospital hos = hospitalDao.findByCode(doc.getHospital());
@ -1076,7 +1087,8 @@ public class FamilyContractService extends BaseService {
                                 long msgid,
                                 String patientCard, int type,
                                 String healthLabel, String customLabel, String disease,
                                 String expenses, long adminTeamCode) throws Exception {
                                 String expenses, long adminTeamCode,
                                 String sevId) throws Exception {
        JSONObject result = new JSONObject();
        String caller = "";
        if (type != 1 && type != 2) {
@ -1101,6 +1113,7 @@ public class FamilyContractService extends BaseService {
            return result;
        }
        String doctorTeamCode = null;//服务团队的CODE;
        //医生同意逻辑
        if (type == 1) {
            //2017-5-27 屏蔽三师签约判断
@ -1183,6 +1196,8 @@ public class FamilyContractService extends BaseService {
            sf.setSignType("1");//患者发起签约
            sf.setExpensesType(StringUtils.isEmpty(expenses) ? "01" : expenses);//收费类别
            sf.setAdminTeamId(adminTeamCode);
            //设置服务类型1.3.3.2版本更新
            signWebService.setSevId(sf,sevId);
            if (StringUtils.isNotEmpty(doctor)) {
                //设置全科医生
                sf.setDoctor(doctor);
@ -1254,6 +1269,9 @@ public class FamilyContractService extends BaseService {
            wlyyDoctorTeamPatient.setCzrq(new Date());
            doctorTeamDoctor.save(wlyyDoctorTeamPatient);
            //设置基卫标识1.3.3.2版本更新
            setSignFamilyMapping(sf.getIdcard(),sf.getSignYear());
        } else {
            // 医生拒绝
            sf.setStatus(-2);
@ -1752,7 +1770,7 @@ public class FamilyContractService extends BaseService {
                jo.put("photo", doctor.getPhoto());
                jo.put("hosptialName", doctor.getHospitalName());
                jo.put("level", doctor.getLevel());
                jo.put("signType", "2");//三师签约
                jo.put("signType", "2");//2是家庭
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctor.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
@ -1772,7 +1790,7 @@ public class FamilyContractService extends BaseService {
                jo.put("photo", doctorHealth.getPhoto());
                jo.put("hosptialName", doctorHealth.getHospitalName());
                jo.put("level", doctorHealth.getLevel());
                jo.put("signType", "2");//三师签约
                jo.put("signType", "2");//2是家庭
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctorHealth.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
@ -2932,19 +2950,29 @@ public class FamilyContractService extends BaseService {
//        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
        Doctor hd = null;
        if(StringUtils.isNotBlank(healthDoctor)){
            hd = doctorDao.findByCode(healthDoctor);
        }
        if (d == null) {
            return -3;
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        Calendar cal = Calendar.getInstance();
        int year =cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH)+1;
        List<SignFamilyRenew> res = signFamilyRenewDao.findByDoctorAndPatientHossPost(doctor,patient,DateUtil.getSignYear()+"");
        if(res!=null&&res.size()>0){
            return -2;
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        String sql = "";
        //判断是否有生效记录SQL
        sql ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='"+(year-1)+"'";
        sql ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='"+(DateUtil.getSignYear()-1)+"'";
        List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
        if(signs==null||signs.size()==0){
@ -2956,9 +2984,11 @@ public class FamilyContractService extends BaseService {
            //如果一致保存团队信息
            sf.setTeamCode((String)sign.get("teamCode"));
            Integer c=(Integer)sign.get("adminTeamCode");
            sf.setRenewFlag("1");
            sf.setAdminTeamId(c.longValue());
        }else {
            //如果不一致 查看医生团队
            sf.setRenewFlag("2");
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
            if(ids!=null&&ids.size()>0){
@ -3070,7 +3100,12 @@ public class FamilyContractService extends BaseService {
            message.setTitle("家庭续签申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            message.setSignStatus("8");//续签
            if("1".equals(sf.getRenewFlag())){
                message.setSignStatus("8");//续签
            }else{
                message.setSignStatus("9");//改签
            }
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(sf.getCode());
@ -3101,11 +3136,21 @@ public class FamilyContractService extends BaseService {
        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
        Doctor hd = null;
        if(StringUtils.isNotBlank(healthDoctor)){
            hd = doctorDao.findByCode(healthDoctor);
        }
        if (d == null) {
            return -3;
        }
        List<SignFamily> res = signFamilyDao.findByDoctorAndPatientHossPost(doctor,patient,DateUtil.getSignYear()+"");
        if(res!=null&&res.size()>0){
            return -2;
        }
        SignFamily sf = new SignFamily();
        Calendar cal = Calendar.getInstance();
@ -3334,4 +3379,30 @@ public class FamilyContractService extends BaseService {
        }
        return jsonArray;
    }
    /**
     * 存储同步纪委标识
     * @param idCard
     * @param signYear
     */
    public void setSignFamilyMapping(String idCard,String signYear){
        SignFamilyMapping maping = new SignFamilyMapping();
        maping.setCode(getCode());
        maping.setCreateTime(new Date());
        maping.setIdcard(idCard);
        maping.setNeedUpdate("0");
        maping.setSignYear(signYear);
        //判断是否是预签约
        //判断规则:如果在4月份到7月份为预签约
        int month = DateUtil.getNowMonth();
        if(month>=4&&month<7){
            //预签约逻辑
            maping.setNeedUpload("0");
            maping.setNeedRenewUpload("1");
        }else{
            maping.setNeedUpload("1");
            maping.setNeedRenewUpload("0");
        }
        signFamilyMappingDao.save(maping);
    }
}

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

@ -6,14 +6,14 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
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.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewLogDao;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
@ -34,7 +34,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.yihu.wlyy.entity.patient.SignWeb;
import com.yihu.wlyy.repository.patient.SignWebDao;
import com.yihu.wlyy.service.BaseService;
@ -71,6 +70,11 @@ public class SignWebService extends BaseService {
    private DoctorDao doctorDao;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private SignPatientLabelInfoService signPatientLabelInfoService;
    @Autowired
    private SignFamilyRenewLogDao signFamilyRenewLogDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -832,8 +836,9 @@ public class SignWebService extends BaseService {
                "    ,b.sex" +
                "    ,b.openid" +
                "    ,a.czrq" +
                "    ,a.renew_flag as renewFlag "+
                " from " +
                " ( select czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " ( select czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin,renew_flag from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc limit " + page * pageSize + "," + pageSize;
@ -858,8 +863,9 @@ public class SignWebService extends BaseService {
                "    ,b.sex" +
                "    ,b.openid" +
                "    ,a.czrq" +
                "    ,a.renew_flag as renewFlag "+
                " from " +
                " ( select czrq,code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ( select czrq,renew_flag,code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and a.expenses_status = '0' order by a.begin desc limit " + page * pageSize + "," + pageSize;
@ -883,8 +889,9 @@ public class SignWebService extends BaseService {
                "    ,b.sex" +
                "    ,b.openid" +
                "    ,a.czrq" +
                "    ,a.renew_flag as renewFlag "+
                " from " +
                " ( select expenses_status,czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " ( select expenses_status,czrq,code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin,renew_flag from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and a.expenses_status = '1' order by a.begin desc limit " + page * pageSize + "," + pageSize;
@ -975,7 +982,12 @@ public class SignWebService extends BaseService {
     * @return
     * @throws Exception
     */
    public int agreeRenew(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear,String code) throws Exception {
    public int agreeRenew(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear, String code,
                          String health,
                          String disease,
                          String custom,
                          String sevId,String healthDoctor,
                          Long teamCode) throws Exception {
//        List<SignFamilyRenew> renews = signFamilyRenewDao.findByDoctorAndPatientStatus0(dotorCode, patientCode, signYear);
//
@ -995,10 +1007,31 @@ public class SignWebService extends BaseService {
                    }
                }
                renew.setApplyDate(new Date());
                //1.3.3.2新增需求
                //设置居民服务类型
                setSevId(renew,sevId);
                //1.3.3.2新增需求
                //设置居民标签
                signPatientLabelInfoService.setRenewPatientLabels(renew.getPatient(), health, disease,custom, renew.getDoctor(),renew.getDoctor());
                //1.3.3.2设置可修改健康管理师
                if(StringUtils.isNotBlank(healthDoctor)){
                    setHealthDoctor(renew,healthDoctor);
                }
                //1.3.3.2设置新团队
                if(teamCode!=null&&teamCode!=0){
                    renew.setAdminTeamId(teamCode);
                }
                signFamilyRenewDao.save(renew);
                setMessState(mesId);
                //1.3.3.2 加入统计日志
                if ("1".equals(state)) {
                   setRenewLog(renew);
                }
                //发送微信模板消息
                JSONObject data = new JSONObject();
                data.put("doctorName", renew.getDoctorName());
@ -1045,26 +1078,26 @@ public class SignWebService extends BaseService {
                }
                //-1患者已取消,-2已拒绝,-3已解约,-4已到期,0待签约,1已签约,2患者申请取消签约,3医生申请取消签约
            }else if(status==1){
            } else if (status == 1) {
                //已经同意
                return 2;
            }else if(status==-1){
            } else if (status == -1) {
                //-1患者已取消
                return 3;
            }else if(status ==-2){
            } else if (status == -2) {
                //已拒绝
                return 4;
            }else if(status ==-3){
            } else if (status == -3) {
                //已解约
                return 5;
            }else if(status ==-4){
            } else if (status == -4) {
                //已到期
                return 6;
            }else{
            } else {
                //已申请取消
                return 7;
            }
        } else{
        } else {
            //未找到签约关系
            return 0;
        }
@ -1081,7 +1114,11 @@ public class SignWebService extends BaseService {
     * @return
     * @throws Exception
     */
    public int agreeRenewOverDue(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear ,String signCode) throws Exception {
    public int agreeRenewOverDue(String access_token, String dotorCode, String patientCode, String state, Long mesId, String signYear, String signCode, String health,
                                 String disease,
                                 String custom,
                                 String sevId,String healthDoctor,
                                 Long teamCode) throws Exception {
//        List<SignFamily> renews = signFamilyDao.findByDoctorAndPatientOverDue(dotorCode, patientCode, signYear);
//
@ -1101,10 +1138,30 @@ public class SignWebService extends BaseService {
                    }
                }
                renew.setApplyDate(new Date());
                //1.3.3.2新增需求
                //设置居民服务类型
                setSevId(renew,sevId);
                //1.3.3.2新增需求
                //设置居民标签
                signPatientLabelInfoService.setPatientLabels(renew.getPatient(), renew.getIdcard(),"", health, disease, custom, renew.getDoctor(), renew.getDoctor());
                //1.3.3.2设置可修改健康管理师
                if(StringUtils.isNotBlank(healthDoctor)){
                    setHealthDoctor(renew,healthDoctor);
                }
                //1.3.3.2设置新团队
                if(teamCode!=null&&teamCode!=0){
                    renew.setAdminTeamId(teamCode);
                }
                signFamilyDao.save(renew);
                //消息设为已读
                setMessState(mesId);
                if ("1".equals(state)) {
                    setRenewLog(renew);
                }
                //发送微信模板消息
                JSONObject data = new JSONObject();
                data.put("doctorName", renew.getDoctorName());
@ -1149,22 +1206,22 @@ public class SignWebService extends BaseService {
                        }
                    }
                }
            }else if(status==1){
            } else if (status == 1) {
                //已经同意
                return 2;
            }else if(status==-1){
            } else if (status == -1) {
                //已拒绝
                return 3;
            }else if(status ==-2){
            } else if (status == -2) {
                //已拒绝
                return 4;
            }else if(status ==-3){
            } else if (status == -3) {
                //已解约
                return 5;
            }else if(status ==-4){
            } else if (status == -4) {
                //已到期
                return 6;
            }else{
            } else {
                //已取消
                return 7;
            }
@ -1217,7 +1274,7 @@ public class SignWebService extends BaseService {
        JSONObject rs = new JSONObject();
        List<SignFamily> signFamilys = signFamilyDao.findByPatientsLastYear(patient,(DateUtil.getNowYear()-1)+"");
        List<SignFamily> signFamilys = signFamilyDao.findByPatientsLastYear(patient, (DateUtil.getNowYear() - 1) + "");
        if (signFamilys == null || signFamilys.size() == 0) {
            throw new RuntimeException("找不到签约关系!");
        }
@ -1468,11 +1525,187 @@ public class SignWebService extends BaseService {
    }
    /**
     * 获取团队签约数,服务次数,平均满意度,
     * @param type
     * @return
     * 设置服务表服务类型
     * @param renew
     * @param sevId
     */
    public void setSevId(SignFamilyRenew renew, String sevId) {
        if (StringUtils.isNotBlank(sevId)) {
            int flag = sevId.indexOf("-");
            if (flag != -1) {
                String sql = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                if (list != null && list.size() > 0) {
                    Map<String, Object> name = list.get(0);
                    String populationName = (String) name.get("name");
                    if (StringUtils.isNotBlank(populationName)) {
                        renew.setSpecialPopulation(sevId);
                        renew.setSpecialPopulationName(populationName);
                    }
                }
                String[] keys = sevId.split("-");
                if (keys != null && keys.length > 0) {
                    String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + keys[0] + "' and d.year ='2017' ";
                    List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
                    if (list2 != null && list2.size() > 0) {
                        Map<String, Object> name = list2.get(0);
                        String serverTypeName = (String) name.get("name");
                        if (StringUtils.isNotBlank(serverTypeName)) {
                            renew.setServerType(keys[0]);
                            renew.setServerTypeName(serverTypeName);
                        }
                    }
                }
            } else {
                String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
                List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
                if (list2 != null && list2.size() > 0) {
                    Map<String, Object> name = list2.get(0);
                    String serverTypeName = (String) name.get("name");
                    if (StringUtils.isNotBlank(serverTypeName)) {
                        renew.setServerType(sevId);
                        renew.setServerTypeName(serverTypeName);
                    }
                }
            }
        }
    }
    /**
     * 设置签约表服务类型
     * @param renew
     * @param sevId
     */
    public JSONArray get(String type){
            return null;
    public void setSevId(SignFamily renew, String sevId) {
        if (StringUtils.isNotBlank(sevId)) {
            int flag = sevId.indexOf("-");
            if (flag != -1) {
                String sql = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                if (list != null && list.size() > 0) {
                    Map<String, Object> name = list.get(0);
                    String populationName = (String) name.get("name");
                    if (StringUtils.isNotBlank(populationName)) {
                        renew.setSpecialPopulation(sevId);
                        renew.setSpecialPopulationName(populationName);
                    }
                }
                String[] keys = sevId.split("-");
                if (keys != null && keys.length > 0) {
                    String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + keys[0] + "' and d.year ='2017' ";
                    List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
                    if (list2 != null && list2.size() > 0) {
                        Map<String, Object> name = list2.get(0);
                        String serverTypeName = (String) name.get("name");
                        if (StringUtils.isNotBlank(serverTypeName)) {
                            renew.setServerType(keys[0]);
                            renew.setServerTypeName(serverTypeName);
                        }
                    }
                }
            } else {
                String sql2 = "select d.name from wlyy_sign_dict d where d.code = '" + sevId + "' and d.year ='2017' ";
                List<Map<String, Object>> list2 = jdbcTemplate.queryForList(sql2);
                if (list2 != null && list2.size() > 0) {
                    Map<String, Object> name = list2.get(0);
                    String serverTypeName = (String) name.get("name");
                    if (StringUtils.isNotBlank(serverTypeName)) {
                        renew.setServerType(sevId);
                        renew.setServerTypeName(serverTypeName);
                    }
                }
            }
        }
    }
    public void setHealthDoctor(SignFamilyRenew signFamilyRenew,String healthDoctor){
        Doctor doctor = doctorDao.findByCode(healthDoctor);
        signFamilyRenew.setDoctorHealth(doctor.getCode());
        signFamilyRenew.setDoctorHealthName(doctor.getName());
    }
    public void setHealthDoctor(SignFamily signFamilyRenew,String healthDoctor){
        Doctor doctor = doctorDao.findByCode(healthDoctor);
        signFamilyRenew.setDoctorHealth(doctor.getCode());
        signFamilyRenew.setDoctorHealthName(doctor.getName());
    }
    public int setRenewLog(SignFamilyRenew renew){
        if(renew ==null) {
            return -1;
        }
        String sql = "SELECT * FROM wlyy_sign_family f WHERE f.patient ='"+renew.getPatient()+"' AND (f.`status` =-4 OR f.`status`>0) AND f.expenses_status ='1' AND f.sign_year >='"+(Integer.parseInt(renew.getSignYear())-1)+"' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Object> sign = null;
        if(list!=null&&list.size()>0){
            sign = list.get(0);
        }
        SignFamilyRenewLog log = new SignFamilyRenewLog();
        //存储新记录
        log.setRenewSignCode(renew.getCode());
        log.setSignYear(renew.getSignYear());
        log.setIdcard(renew.getIdcard());
        log.setAdminTeamId(renew.getAdminTeamId());
        log.setDoctor(renew.getDoctor());
        log.setHospital(renew.getHospital());
        //存储旧签约记录
        if(sign!=null){
            Integer id =(Integer) sign.get("admin_team_code");
            log.setOldSignCode((String)sign.get("code"));
            log.setOldAdminTeamId(id.longValue());
            log.setOldHospital((String)sign.get("hospital"));
            log.setOldDoctor((String)sign.get("doctor"));
        }
        log.setNeedUpload("1");
        log.setCreateTime(new Date());
        log.setUpdateTime(new Date());
        signFamilyRenewLogDao.save(log);
        return 1;
    }
    public int setRenewLog(SignFamily renew){
        if(renew ==null) {
            return -1;
        }
        String sql = "SELECT * FROM wlyy_sign_family f WHERE f.patient ='"+renew.getPatient()+"' AND (f.`status` =-4 OR f.`status`>0) AND f.expenses_status ='1' AND f.sign_year >='"+(Integer.parseInt(renew.getSignYear())-1)+"' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Map<String,Object> sign = null;
        if(list!=null&&list.size()>0){
            sign = list.get(0);
        }
        SignFamilyRenewLog log = new SignFamilyRenewLog();
        //存储新记录
        log.setSignCode(renew.getCode());
        log.setSignYear(renew.getSignYear());
        log.setIdcard(renew.getIdcard());
        log.setAdminTeamId(renew.getAdminTeamId());
        log.setDoctor(renew.getDoctor());
        log.setHospital(renew.getHospital());
        //存储旧签约记录
        if(sign!=null){
            Integer id =(Integer) sign.get("admin_team_code");
            log.setOldSignCode((String)sign.get("code"));
            log.setOldAdminTeamId(id.longValue());
            log.setOldHospital((String)sign.get("hospital"));
            log.setOldDoctor((String)sign.get("doctor"));
        }
        log.setNeedUpload("1");
        log.setCreateTime(new Date());
        log.setUpdateTime(new Date());
        signFamilyRenewLogDao.save(log);
        return 1;
    }
}

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

@ -6,12 +6,14 @@ import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
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.app.hospital.HospitalService;
import org.apache.commons.lang3.tuple.ImmutablePair;
@ -50,7 +52,8 @@ public class AdminTeamService extends BaseService {
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    SignFamilyRenewDao signFamliyRenewDao;
    @Autowired
    HospitalDao hospitalDao;
@ -359,6 +362,25 @@ public class AdminTeamService extends BaseService {
        return result;
    }
    /**
     * 查询居民与医生的签约团队
     *
     * @param patient 居民
     * @param doctor  医生
     * @return
     */
    public JSONArray findRenewPatientDoctorTeam(String patient, String doctor) {
        JSONArray result = new JSONArray();
        SignFamilyRenew jtSign = signFamliyRenewDao.findSignByPatient(patient, 2);
        if (jtSign.getAdminTeamId()!=null&&jtSign != null && (doctor.equals(jtSign.getDoctor())
                || doctor.equals(jtSign.getDoctorHealth()))) {
            AdminTeam team = getTeam(jtSign.getAdminTeamId());
            result.put(new JSONObject(team));
        }
        return result;
    }
    /**
     * 查询机构下团队
     *

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

@ -6,11 +6,14 @@
package com.yihu.wlyy.service.common.account;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.ServerLabelTree;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
@ -23,6 +26,7 @@ import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -35,10 +39,7 @@ import org.springside.modules.utils.Clock;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 患者基本信息类.
@ -58,6 +59,8 @@ public class PatientService extends TokenService {
    @Autowired
    private DoctorPatientDao doctorPatientDao;
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    TokenDao tokenDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
@ -488,5 +491,129 @@ public class PatientService extends TokenService {
        return "";
    }
    /**
     * 获取数据字典
     * @return
     */
    public JSONArray getSigndict(String signYear){
        String sql = null;
        if (StringUtils.isNotBlank(signYear)){
            sql =   " select d.`code`,d.`name` " +
                    " from wlyy_sign_dict d where d.type IN('1','2') AND d.year ='"+signYear+"' AND d.`code` " +
                    " NOT IN(select LEFT(d.code,(INSTR(d.code, '-')-1)) as code from wlyy_sign_dict d WHERE d.code LIKE '%-%' GROUP BY code)";
        }else{
            sql = " select d.`code`,d.`name` " +
                    " from wlyy_sign_dict d where d.type IN('1','2') AND d.year ='"+DateUtil.getSignYear()+"' AND d.`code` " +
                    " NOT IN(select LEFT(d.code,(INSTR(d.code, '-')-1)) as code from wlyy_sign_dict d WHERE d.code LIKE '%-%' GROUP BY code)";
        }
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
        JSONArray rsJs = new JSONArray(rs);
        return rsJs;
    }
    public JSONArray getSigndictTree(Long teamCodo){
        String sql1 = "SELECT * FROM wlyy_sign_dict t WHERE t.`year` = '"+DateUtil.getSignYear()+"' AND t.`code` NOT LIKE '%-%'";
        String sql2 = "SELECT * FROM wlyy_sign_dict t WHERE t.`year` = '"+DateUtil.getSignYear()+"' AND t.`code` LIKE '%-%'";
        String signServerfousSql = "SELECT COUNT(1) AS fouCount FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCodo+" AND f.`status`>0 AND f.expenses_status ='1' AND f.openid IS NOT NULL AND f.server_type =?";
        String signServerSql = "SELECT COUNT(1) AS total FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCodo+" AND f.`status`>0 AND f.expenses_status ='1' AND f.server_type =?";
        String signSesFousSql = "SELECT COUNT(1) AS fouCount FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCodo+" AND f.`status`>0 AND f.expenses_status ='1' AND f.openid IS NOT NULL AND f.special_population =?";
        String signSesSql ="SELECT COUNT(1) AS total FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCodo+" AND f.`status`>0 AND f.expenses_status ='1'AND f.special_population =?";
        List<Map<String,Object>> rs1 = jdbcTemplate.queryForList(sql1);
        List<Map<String,Object>> rs2 = jdbcTemplate.queryForList(sql2);
        List<ServerLabelTree> tree = new ArrayList<>();
        if(rs1!=null&&rs1.size()>0){
            for(Map<String,Object> map :rs1){
                ServerLabelTree t = new ServerLabelTree();
                String code = (String)map.get("code");
                t.setLabelCode(code);
                t.setLabelName((String)map.get("name"));
                //计算总数
                List<Map<String,Object>> list = jdbcTemplate.queryForList(signServerSql,new Object[]{code});
                //计算关注度
                List<Map<String,Object>> list2 = jdbcTemplate.queryForList(signServerfousSql,new Object[]{code});
                if(list!=null&&list.size()>0){
                    Map<String,Object> cout = list.get(0);
                    t.setAmount((Long)cout.get("total"));
                }else{
                    t.setAmount(0L);
                }
                if(list2!=null&&list2.size()>0){
                    Map<String,Object> cout = list2.get(0);
                    t.setFocusAmount((Long)cout.get("fouCount"));
                }else{
                    t.setFocusAmount(0L);
                }
                List<ServerLabelTree> ch = new ArrayList<>();
                for(Map<String,Object> m :rs2){
                    String c = (String)m.get("code");
                    String[] cc = c.split("-");
                    if(code.equals(cc[0])){
                        ServerLabelTree cht = new ServerLabelTree();
                        cht.setLabelCode(c);
                        cht.setLabelName((String)m.get("name"));
                        //计算总数
                        List<Map<String,Object>> l = jdbcTemplate.queryForList(signSesSql,new Object[]{cc[1]});
                        //计算关注度
                        List<Map<String,Object>> l2 = jdbcTemplate.queryForList(signSesFousSql,new Object[]{cc[1]});
                        if(l!=null&&l.size()>0){
                            Map<String,Object> cout = l.get(0);
                            cht.setAmount((Long)cout.get("total"));
                        }else{
                            cht.setAmount(0L);
                        }
                        if(l2!=null&&l2.size()>0){
                            Map<String,Object> cout = l2.get(0);
                            cht.setFocusAmount((Long)cout.get("fouCount"));
                        }else{
                            cht.setFocusAmount(0L);
                        }
                        ch.add(cht);
                    }
                }
                t.setCh(ch);
                tree.add(t);
            }
        }
       return new JSONArray(tree);
    }
    public String getTeamNameByTeamCode(Long id){
        AdminTeam adminTeam =  doctorAdminTeamDao.findOne(id);
        return adminTeam.getName();
    }
    public JSONArray getSignByTeamCodeGpbyServer(String teamCode){
        // 获取总分组数量
        String totalGSql = "SELECT count(1) AS Amount,f.server_type,f.server_type_name FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCode+" AND f.`status`>0 AND f.expenses_status ='1' GROUP BY f.server_type ";
        List<Map<String,Object>> totalG = jdbcTemplate.queryForList(totalGSql);
        //获取关注量分组数量
        String fousGSql ="SELECT count(1) As focusAmount,f.server_type,f.server_type_name FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCode+" AND f.`status`>0 AND f.expenses_status ='1' AND f.openid IS NOT NULL GROUP BY f.server_type ";
        List<Map<String,Object>> fousG = jdbcTemplate.queryForList(fousGSql);
        //获取二级节点分组总数
        String sesTotalSql ="SELECT count(1) AS Amount,f.server_type,f.server_type_name,f.special_population,f.special_population_name FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCode+" AND f.`status`>0 AND f.expenses_status ='1' AND f.special_population Is NOT NULL GROUP BY f.special_population ";
        List<Map<String,Object>> sesTotal = jdbcTemplate.queryForList(sesTotalSql);
        //获取二级节点分组数量
        String sesFousGSql ="SELECT count(1) AS Amount,f.server_type,f.server_type_name,f.special_population,f.special_population_name FROM wlyy_sign_family f WHERE f.admin_team_code ="+teamCode+" AND f.`status`>0 AND f.expenses_status ='1' AND f.special_population Is NOT NULL AND f.openid IS NOT NULL GROUP BY f.special_population ";
        List<Map<String,Object>> sesFousG =jdbcTemplate.queryForList(sesFousGSql);
        if(totalG!=null&&totalG.size()>0){
            Map<String,Object> fousGMap = new HashMap<>();
            if(fousG!=null&&fousG.size()>0){
                 //将List转换为Map 降低循环层级
                for(Map<String,Object> fg: fousG){
                }
            }
        }
        return null;
    }
}

+ 8 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -818,4 +818,12 @@ public class DateUtil {
		ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
		return format.format(ca.getTime());
	}
	public static int getSignYear(){
		Calendar ca = Calendar.getInstance();
		if(getNowMonth()>=4){
			return getNowYear();
		}
		return getNowYear()-1;
	}
}

+ 9 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -238,7 +238,7 @@ public class SignPatientLabelInfoController extends BaseController {
     * @return
     */
    @RequestMapping(value = "/label_patient_amount")
    public String getPatientAmountByLabelType(String labelType, @RequestParam(required = false) Long teamCode) {
    public String getPatientAmountByLabelType(@RequestParam(required = false)String labelType, @RequestParam(required = false) Long teamCode) {
        try {
            if (StringUtils.isEmpty(labelType)) {
                return error(-1, "标签类型不能为空");
@ -319,7 +319,10 @@ public class SignPatientLabelInfoController extends BaseController {
     * @return
     */
    @RequestMapping(value = "/patient_label_update")
    public String setPatientLabels(String patient, String health, String disease, String custom) {
    public String setPatientLabels(@RequestParam(required = false) String patient,
                                   @RequestParam(required = false) String health,
                                   @RequestParam(required = false) String disease,
                                   @RequestParam(required = false) String custom) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
@ -327,8 +330,9 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(health)) {
                return error(-1, "健康情况标签不能为空");
            }
            //xh1D201703150222
            int result = labelInfoService.setPatientLabels(patient, "", "", health, disease, custom, getUID(), getUID());
            //int result = labelInfoService.setPatientLabels(patient, "", "", health, disease, custom, "xh1D201703150222", "xh1D201703150222");
            if (result == 0) {
                return error(-1, "查不到患者信息");
@ -370,9 +374,9 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
            }
            //D2016008240002
            JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType, teamCode, getUID());
            //JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType, teamCode, "D2016008240002");
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
            e.printStackTrace();

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

@ -408,8 +408,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            @RequestParam(required = false) String signDoctorCode,//簽約人code
            @RequestParam(required = false) String signDoctorName,//簽約人銘
            @RequestParam(required = false) String signDoctorLevel,//簽約人等级
            @RequestParam(required = false) long adminTeamCode //行政团队
    ) {
            @RequestParam(required = false) long adminTeamCode, //行政团队
            @RequestParam(required = false) String sevId) {
        try {
            if (StringUtils.isEmpty(idcard)) {
                return error(-1, "请输入身份证号!");
@ -465,10 +465,10 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            //}
            /**end**/
            Doctor cDoctor = doctorService.findDoctorByCode(getUID());
            SignFamily sf = familyContractService.agent(getAccessToken(), name, doctor, doctorName,
                    healthDoctor, healthDoctorName, cDoctor.getHospital(), cDoctor.getHospitalName(),
                    idcard, ssc, mobile, emerMobile, images, healthLabel, customLabel, disease, expenses, signDoctorCode, signDoctorName, signDoctorLevel, adminTeamCode);
                    idcard, ssc, mobile, emerMobile, images, healthLabel, customLabel, disease, expenses, signDoctorCode, signDoctorName, signDoctorLevel, adminTeamCode,sevId);
            if (sf == null) {
                return error(-1, "代理签约失败!");
            } else {
@ -514,7 +514,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            String patientIDcard,
            int type,
            long adminTeamCode,
            @RequestParam(required = false, defaultValue = "0") String expenses) {
            @RequestParam(required = false, defaultValue = "0") String expenses,
            @RequestParam(required = true) String sevId) {
        try {
            if (type != 2) {
                try {
@ -549,7 +550,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "健康情况标签不能为空!");
            }
            JSONObject res = familyContractService.handleSign(signType, getAccessToken(), doctor, doctorName, healthDoctor, healthDoctorName, msgid, patientIDcard, type, healthLabel, customLabel, disease, expenses, adminTeamCode);
            JSONObject res = familyContractService.handleSign(signType, getAccessToken(), doctor, doctorName, healthDoctor, healthDoctorName, msgid, patientIDcard, type, healthLabel, customLabel, disease, expenses, adminTeamCode,sevId);
            if (res.getInt("status") == -1) {
                return error(-1, "未知的处理类型!");
            } else if (res.getInt("status") == 0) {

+ 61 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -382,6 +382,7 @@ public class DoctorSignController extends WeixinBaseController {
                    json.put("status", temp.get("status"));
                    json.put("openid", temp.get("openid"));
                    json.put("renewTime", temp.get("czrq"));
                    json.put("renewFlag",temp.get("renewFlag"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
@ -446,7 +447,13 @@ public class DoctorSignController extends WeixinBaseController {
    public String agreeRenew(@RequestParam(required = true)String state,
                             @RequestParam(required = true)String patient,
                             @RequestParam(required = false) Long mesId,
                             @RequestParam(required = false)String signCode){
                             @RequestParam(required = false)String signCode,
                             @RequestParam(required = true) String health,
                             @RequestParam(required = true) String disease,
                             @RequestParam(required = true) String custom,
                             @RequestParam(required = true) String sevId,
                             @RequestParam(required = false) String healthDoctor,
                             @RequestParam(required = false) Long teamCode){
        try{
            //判断是否存在下个年度续签
            int isNowYearSign = signWebService.checkNowYearSign(getUID(),patient);
@ -461,13 +468,13 @@ public class DoctorSignController extends WeixinBaseController {
            int month = cal.get(Calendar.MONTH)+1;
            int rs = 0;
            if(month<7){
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode);
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode);
//            int rs =signWebService.agreeRenew(getAccessToken(),"test00000000005",patient,state);
            }else{
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode);
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode);
                //如果没有续签记录,走签约记录
                if(rs!=0){
                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode);
                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode);
                }
            }
            if(rs != 1){
@ -576,4 +583,54 @@ public class DoctorSignController extends WeixinBaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取签约字典数据
     * @return
     */
    @RequestMapping(value = "/getSigndict", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getSigndict(@RequestParam(required = false) String signYear){
        try {
            JSONArray result = patientService.getSigndict(signYear);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取签约字典数据
     * @return
     */
    @RequestMapping(value = "/getSigndictTree", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getSigndictTree(@RequestParam(required = true) Long teamCode){
        try {
            JSONArray result = patientService.getSigndictTree(teamCode);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     *  获取团队名称
     * @return
     */
    @RequestMapping(value = "/getTeamNameByTeamCode", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String getTeamNameByTeamCode(@RequestParam(required = true) Long teamCode){
        try {
            String result = patientService.getTeamNameByTeamCode(teamCode);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
}

+ 3 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -493,8 +493,8 @@ public class FamilyContractController extends BaseController {
    @RequestMapping(value = "signRenew")
    @ResponseBody
    public String signRenew(@RequestParam(required = true) String doctor,
                            @RequestParam(required = true) String healthDoctor,
                            @RequestParam(required = true) String patient) {
                            @RequestParam(required = false) String healthDoctor,
                            @RequestParam(required = false) String patient) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
@ -512,7 +512,7 @@ public class FamilyContractController extends BaseController {
            if (result == -1) {
                return error(-1, "用户信息查询失败");
            } else if (result == -2) {
                return error(-1, "用户已存在签约");
                return error(-1, "续签已经提交");
            } else if (result == -3) {
                return error(-1, "医生信息查询失败");
            } else if (result == -4) {