Переглянути джерело

居民颜色定标同步JOB,红色定标居民增加重点关注和自动跟踪

huangwenjie 7 роки тому
батько
коміт
f9dbec1804

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/doctor/DoctorSwitchDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.doctor;
/**
 * @author huangwenjie
 * @date 2018/1/28 16:29
 */
import com.yihu.wlyy.entity.doctor.DoctorSwitch;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/5.
 */
public interface DoctorSwitchDao extends PagingAndSortingRepository<DoctorSwitch, Long>, JpaSpecificationExecutor<DoctorSwitch> {
	public DoctorSwitch findByDoctor(String doctor);
}

+ 13 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/doctor/PatientAimBloodPressureDao.java

@ -0,0 +1,13 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.patient.PatientAimBloodPressure;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author huangwenjie
 * @date 2018/1/28 16:34
 */
public interface PatientAimBloodPressureDao extends PagingAndSortingRepository<PatientAimBloodPressure, Integer>, JpaSpecificationExecutor<PatientAimBloodPressure> {
	public  PatientAimBloodPressure findByPatientcode(String patientcode);
}

+ 14 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/doctor/PatientAimBloodSuggerDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.patient.PatientAimBloodSugger;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author huangwenjie
 * @date 2018/1/28 16:32
 */
public interface PatientAimBloodSuggerDao extends PagingAndSortingRepository<PatientAimBloodSugger, Integer>, JpaSpecificationExecutor<PatientAimBloodSugger> {
	
	public PatientAimBloodSugger findByPatientcode(String patientcode);
}

+ 18 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/TrackPatientDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.TrackPatient;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author huangwenjie
 * @date 2018/1/28 16:30
 */
public interface TrackPatientDao extends PagingAndSortingRepository<TrackPatient, String>, JpaSpecificationExecutor<TrackPatient> {
	
	public TrackPatient findByDoctorCodeAndPatientCode(String doctorCode,String patientCode);
	
	public List<TrackPatient> findByDoctorCodeAndTeamCodeAndDel(String doctorCode, Integer teamCode, String del);
}

+ 126 - 7
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -5,19 +5,16 @@
 *******************************************************************************/
package com.yihu.wlyy.service.common.account;
import com.yihu.wlyy.entity.doctor.DoctorSwitch;
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.patient.*;
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.doctor.*;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.TrackPatientDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.EncodesUtil;
@ -65,6 +62,14 @@ public class PatientService extends TokenService {
    @Autowired
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Autowired
    private PatientAimBloodSuggerDao patientAimBloodSuggerDao;
    @Autowired
    private PatientAimBloodPressureDao patientAimBloodPressureDao;
    @Autowired
    TokenDao tokenDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
@ -1019,4 +1024,118 @@ public class PatientService extends TokenService {
        }
    }
    
    /**
     * //1.4.2加入重点关注逻辑
     * 红色定标居民加入重点关注
     * @param idcard_red_diseasecontion_map
     */
    public void setTrackPatientByDoctor(HashMap<String, Integer> idcard_red_diseasecontion_map) {
        
        Set<String> patient_idcards = idcard_red_diseasecontion_map.keySet();
    
        for (String idcard: patient_idcards) {
            Patient p = patientDao.findByIdcard(idcard);
            if(p==null){
                logger.info("居民idcard:"+idcard+";未找到该居民");
                continue;
            }
    
            SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(p.getCode());
            if(signFamily==null){
                logger.info("居民idcard:"+idcard+";该居民未签约家庭医生");
                continue;
            }
    
            //医生是否自动追踪居民
            DoctorSwitch sw =  doctorSwitchDao.findByDoctor(signFamily.getDoctor());
            DoctorSwitch swh =  doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
    
            if(sw!=null){
                if("1".equals(sw.getAlertPatientSwitch())){
                    //查询是否与医生建立重点跟踪关系,诺无关系则建立
                    TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),p.getCode());
            
                    if(trackPatient == null){
                        TrackPatient t = new TrackPatient();
                        t.setCreateTime(new Date());
                        t.setDoctorCode(signFamily.getDoctor());
                        t.setDoctorName(signFamily.getDoctorName());
                        t.setIdcard(signFamily.getIdcard());
                        t.setSsc(signFamily.getSsc());
                        t.setTeamCode(signFamily.getAdminTeamId().intValue());
                        t.setPatientCode(p.getCode());
                        t.setPatientName(p.getName());
                        t.setDel("1");
                        trackPatientDao.save(t);
                        //设置默认控制目标
                        setDefaultAim(p.getCode());
                    }else{
                        trackPatient.setDel("1");
                        trackPatientDao.save(trackPatient);
                    }
                }
            }
    
            if(swh!=null){
                if("1".equals(sw.getAlertPatientSwitch())){
                    //查询是否与医生建立重点跟踪关系,诺无关系则建立
                    TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),p.getCode());
                    if(trackPatient == null){
                        TrackPatient t = new TrackPatient();
                        t.setCreateTime(new Date());
                        t.setDoctorCode(signFamily.getDoctorHealth());
                        t.setDoctorName(signFamily.getDoctorHealthName());
                        t.setIdcard(signFamily.getIdcard());
                        t.setSsc(signFamily.getSsc());
                        t.setTeamCode(signFamily.getAdminTeamId().intValue());
                        t.setPatientCode(p.getCode());
                        t.setPatientName(p.getName());
                        t.setDel("1");
                        trackPatientDao.save(t);
                        //设置默认控制目标
                        setDefaultAim(p.getCode());
                    }else{
                        trackPatient.setDel("1");
                        trackPatientDao.save(trackPatient);
                    }
                }
            }
        }
    }
    
    /**
     * 设置默认监控方案
     * @param patient
     * @return
     */
    public String setDefaultAim(String patient){
        PatientAimBloodSugger patientAimBloodSugger = patientAimBloodSuggerDao.findByPatientcode(patient);
        PatientAimBloodPressure patientAimBloodPressure =  patientAimBloodPressureDao.findByPatientcode(patient);
        if(patientAimBloodSugger==null){
            PatientAimBloodSugger pa = new PatientAimBloodSugger();
            pa.setPatientcode(patient);
            pa.setCode(getCode());
            pa.setCreateTime(new Date());
            pa.setUnit("mmol/L");
            pa.setFbg("7.0");
            pa.setHpg("11.1");
            pa.setFbgMin("4.0");
            pa.setHpgMin("4.0");
            patientAimBloodSuggerDao.save(pa);
        }
        if(patientAimBloodPressure==null){
            PatientAimBloodPressure pa = new PatientAimBloodPressure();
            pa.setPatientcode(patient);
            pa.setCode(getCode());
            pa.setCreateTime(new Date());
            pa.setSbp("140");
            pa.setSbpMin("90");
            pa.setDbp("90");
            pa.setDbpMin("60");
            pa.setUnit("mmHg");
            patientAimBloodPressureDao.save(pa);
        }
        return "1";
    }
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -320,8 +320,12 @@ public class JwPrescriptionService {
        params.add(new BasicNameValuePair("TIME_END", enddate));//结束时间
        String response = httpClientUtil.post(url, params, "UTF-8");
    
        //全部定标的居民集合
        HashMap<String, Integer> idcard_diseasecontion_map = new HashMap<>();
    
        //红色定标的居民集合
        HashMap<String, Integer> idcard_red_diseasecontion_map = new HashMap<>();
    
        if (StringUtils.isNotBlank(response)) {
            JSONObject reobj = JSON.parseObject(response);
            Integer status = reobj.getInteger("status");
@ -336,11 +340,24 @@ public class JwPrescriptionService {
                        String idcard = json.getString("IDENTITY_CARD_NO");//身份证号码
                        Integer diseaseCondition = json.getInteger("SPECIALIST_CONTROL");//定标情况【 0 绿标 1 黄标 2 红标】
                        idcard_diseasecontion_map.put(idcard, diseaseCondition);
                        
                        //过滤出红色定标的居民集合
                        if(2 == diseaseCondition){
                            idcard_red_diseasecontion_map.put(idcard, diseaseCondition);
                        }
                    }
    
                    if (idcard_diseasecontion_map != null && !idcard_diseasecontion_map.keySet().isEmpty()) {
                        logger.info("从基卫接口获取需要更新定标情况的慢病患者个数为" + idcard_diseasecontion_map.keySet().size());
                        patientService.updatePatientDiseascontionByIdcard(idcard_diseasecontion_map);
                        
                        
                        //红色定标的居民单独处理
                        if(idcard_red_diseasecontion_map != null && !idcard_red_diseasecontion_map.isEmpty()){
                            //1.4.2加入重点关注逻辑
                            patientService.setTrackPatientByDoctor(idcard_red_diseasecontion_map);
                        }
                        
                    } else {
                        logger.info("从基卫接口获取需要更新定标情况的慢病患者个数为" + idcard_diseasecontion_map.keySet().size());
                    }