Quellcode durchsuchen

长处方续方取消,关联的随访记录也取消

huangwenjie vor 7 Jahren
Ursprung
Commit
cc97aa85b3

+ 8 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/FollowupDao.java

@ -18,4 +18,12 @@ public interface FollowupDao extends PagingAndSortingRepository<Followup, Long>,
    @Query("select a from Followup a where a.doctorCode = ?1 and a.followupDate between ?2 and ?3 and a.status <> '0'")
    List<Followup> findByDoctor(String doctor, Date begin, Date end, Pageable pageRequest) throws Exception;
    
    /**
     * 根据续方CODE获取随访记录
     * @param prescriptionCode
     * @return
     */
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.status <> '0'")
    Followup getFollowupByPrescriptionCode(String prescriptionCode);
}

+ 12 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/Followup.java

@ -50,8 +50,18 @@ public class Followup extends IdEntity {
	private String followupContentPhone;
	//创建时间
	private Date createTime;
	
	//关联的续方CODE
	private String prescriptionCode;
	
	public String getPrescriptionCode() {
		return prescriptionCode;
	}
	
	public void setPrescriptionCode(String prescriptionCode) {
		this.prescriptionCode = prescriptionCode;
	}
	
	public String getFollowupNo() {
		return followupNo;
	}

+ 14 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -79,6 +79,8 @@ public class PrescriptionService extends ZysoftBaseService{
    private AmoutUtils amoutUtils;
    @Autowired
    private ZyIvPhysicDictDao zyIvPhysicDictDao;
    @Autowired
    private FollowupDao followupDao;
    /**
     * 新增续方日志
@ -1130,6 +1132,18 @@ public class PrescriptionService extends ZysoftBaseService{
                log.setUserCode(prescription.getDoctor());
                log.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_refund.getValue());
                prescriptionLogDao.save(log);
                
                try {
                    //续方取消,随访记录也取消,这里如果抛错,则捕获记录日志,不往外抛异常,避免影响长处方的逻辑
                    Followup followup = followupDao.getFollowupByPrescriptionCode(prescription.getCode());
                    if(followup !=null){
                        followup.setStatus("0");
                        followupDao.save(followup);
                    }
                }catch (Exception e){
                    logger.info("取消随访记录失败,:"+e.getMessage());
                }
                
            }
        
        }catch (JSONException ex){

+ 16 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayOverdueJob.java

@ -2,8 +2,10 @@ package com.yihu.wlyy.job;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
@ -36,6 +38,8 @@ public class PrescriptionPayOverdueJob implements Job {
    private String jwUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private FollowUpDao followUpDao;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Override
@ -117,6 +121,18 @@ public class PrescriptionPayOverdueJob implements Job {
                }
                prescription.setZyCancelState(1);
                prescriptionDao.save(prescription);
    
                try {
                    //续方取消,随访记录也取消,这里如果出错则直接捕获,记录日志,不往外抛,避免影响长处方逻辑
                    Followup followup = followUpDao.getFollowupByPrescriptionCode(prescriptionCode);
                    if(followup !=null){
                        followup.setStatus("0");
                        followUpDao.save(followup);
                    }
                }catch (Exception e){
                    logger.info("续方取消,随访记录同步取消失败:"+e.getMessage());
                }
                
            }else{
                throw new Exception("基卫接口(挂号作废)请求失败,无数据返回!");
            }

+ 8 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java

@ -35,4 +35,12 @@ public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>,
    
    @Query(value = "select a.* from wlyy_followup a INNER JOIN  wlyy_followup_mapping b on b.followup_id = a.id AND b.need_upload=?1",nativeQuery = true)
	List<Followup> findByFollowMappingNeedUpload(Integer need_upload);
    
    /**
     * 根据续方CODE获取随访记录
     * @param prescriptionCode
     * @return
     */
    @Query("select a from Followup a where a.prescriptionCode = ?1 and a.status <> '0'")
    Followup getFollowupByPrescriptionCode(String prescriptionCode);
}

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

@ -551,6 +551,10 @@ public class PrescriptionInfoService extends BaseService {
            if (s > 86400) {
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue());
                prescriptionDao.save(prescription);
    
                //取消长处方关联的随访记录
                canclePrescriptionFollowup(code);
            }
        } else {
            //rs.put("time","");
@ -615,6 +619,9 @@ public class PrescriptionInfoService extends BaseService {
        //同步智业接口
        jwPrescriptionService.fadeRecipe(code);
    
        //取消长处方关联的随访记录
        canclePrescriptionFollowup(code);
        return 1;
    }
@ -912,6 +919,9 @@ public class PrescriptionInfoService extends BaseService {
                //审核不通过模板消息
                sendRMess(p.getCode(), 0);
    
                //取消长处方关联的随访记录
                canclePrescriptionFollowup(code);
            }
            prescriptionReviewedDao.save(reviewed);
            prescriptionDao.save(p);
@ -1854,4 +1864,22 @@ public class PrescriptionInfoService extends BaseService {
        }
        return jsonObject;
    }
    
    /**
     * 根据长处方CODE,取消关联的随访记录
     * @param prescriptionCode
     */
    private void canclePrescriptionFollowup(String prescriptionCode){
        try {
            //续方取消,随访记录也取消,这里如果出错则直接捕获,记录日志,不往外抛,避免影响长处方逻辑
            Followup followup = followUpDao.getFollowupByPrescriptionCode(prescriptionCode);
            if(followup !=null){
                followup.setStatus("0");
                followUpDao.save(followup);
            }
        }catch (Exception e){
            logger.info("续方取消,随访记录同步取消失败:"+e.getMessage());
        }
    }
}

+ 14 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
@ -11,6 +12,7 @@ import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
@ -73,9 +75,8 @@ public class PrescriptionService extends BaseService {
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private JpaTransactionManager transactionManager;
    @Autowired
    private com.yihu.wlyy.util.CommonUtil commonUtil;
    private FollowUpDao followUpDao;
    /**
@ -431,6 +432,17 @@ public class PrescriptionService extends BaseService {
                        statusObj.put("status",200);
                        statusObj.put("code",9);
                        statusObj.put("message","基卫处方为作废,已修改本地数据库该处方为线下取消");
    
                        try {
                            //续方取消,随访记录也取消,这里如果出错则直接捕获,记录日志,不往外抛,避免影响长处方逻辑
                            Followup followup = followUpDao.getFollowupByPrescriptionCode(prescriptionCode);
                            if(followup !=null){
                                followup.setStatus("0");
                                followUpDao.save(followup);
                            }
                        }catch (Exception e){
                            logger.info("续方取消,随访记录同步取消失败:"+e.getMessage());
                        }
                    }else{
                        statusObj.put("status",200);
                        statusObj.put("code",data.getString("RECIPE_STATUS_CODE"));