Sfoglia il codice sorgente

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

chenweida 7 anni fa
parent
commit
ba71917893
21 ha cambiato i file con 447 aggiunte e 32 eliminazioni
  1. 17 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  2. 8 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/FollowupDao.java
  3. 12 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/Followup.java
  4. 38 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  5. 1 0
      patient-co-service/wlyy_service/src/main/resources/application.yml
  6. 2 2
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/UploadChargeThread.java
  7. 5 5
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/UploadThread.java
  8. 2 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/SignFamilyRenewLogDao.java
  9. 50 1
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java
  10. 16 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayOverdueJob.java
  11. 8 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/followup/FollowUpDao.java
  12. 20 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  13. 56 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java
  14. 59 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  15. 14 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  16. 8 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java
  17. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  18. 43 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java
  19. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java
  20. 13 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  21. 55 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

+ 17 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java

@ -339,6 +339,23 @@ public class PrescriptionController extends BaseController{
			return Result.error(ex.getMessage());
		}
	}
	
	@RequestMapping(value = "getZyDataStatus",method = RequestMethod.POST)
	@ApiOperation("获取基卫处方的相关数据状态")
	public Result getZyDataStatus(@ApiParam(name="type",value="数据类型:1:挂号数据;2:处方数据;3:结算数据",defaultValue = "")
	                            @RequestParam(value = "type",required = true) String type,
	                            @ApiParam(name="jwid",value="基卫处方ID",defaultValue = "")
	                            @RequestParam(value = "jwid",required = true) String jwid,
	                            @ApiParam(name="hosipital",value="基卫机构编码",defaultValue = "")
	                            @RequestParam(value = "hosipital",required = true) String hosipital){
		try {
			String re = prescriptionService.getZyDataStatus(type,jwid,hosipital);
			return Result.success("查询成功!",re);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	/************************************ CA认证 ************************************************************/
	@RequestMapping(value = "RequestRealNameSoftCertAndSign",method = RequestMethod.POST)

+ 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;
	}

+ 38 - 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){
@ -1178,4 +1192,28 @@ public class PrescriptionService extends ZysoftBaseService{
    
        return response;
    }
    
    /**
     * 获取基卫处方的相关数据状态
     * @param type
     * @param jwid
     * @param hosipital
     * @return
     */
    public String getZyDataStatus(String type, String jwid, String hosipital)  throws Exception{
        String[] hospitalMapping = getHospitalMapping(hosipital); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
    
        Map<String,String> params = new HashMap<>();
        params.put("type",type);
        params.put("id",jwid);
    
        String response = postSecond("getDataStatus","获取基卫处方的相关数据状态",params,null,header,false,2,"2");
    
        return response;
    }
}

+ 1 - 0
patient-co-service/wlyy_service/src/main/resources/application.yml

@ -51,6 +51,7 @@ spring:
zysoftApi:
  internet: internet/CallEhrInterface
  base: base/CallEhrInterface
  imm: imm/Action
redisChannel:
    prescription: redisMessage

+ 2 - 2
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/UploadChargeThread.java

@ -29,7 +29,7 @@ public class UploadChargeThread implements Runnable{
                {
                    Boolean running = systemDictService.getUploadChargeRunning();
                    if(running) {
                        System.out.print(DateUtil.dateToStrLong(now) + " 上传缴费...\r\n");
//                        System.out.print(DateUtil.dateToStrLong(now) + " 上传缴费...\r\n");
                        try {
                            service.uploadCharge();
                        }
@ -38,7 +38,7 @@ public class UploadChargeThread implements Runnable{
                            e.printStackTrace();
                        }
                        System.out.print(DateUtil.dateToStrLong(new Date()) + " 上传缴费记录结束。\r\n");
//                        System.out.print(DateUtil.dateToStrLong(new Date()) + " 上传缴费记录结束。\r\n");
                    }
                    Thread.sleep(sleepTime);

+ 5 - 5
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/UploadThread.java

@ -30,8 +30,8 @@ public class UploadThread implements Runnable {
                Date now = new Date();
                //判断非空闲时候
                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)
                {
//                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)---2017.11.15修改为不判断空闲非空闲
//                {
                    //签约上传
                    SignZYService signZYService = (SignZYService) SpringContextHolder.getSpringBean("SignZYService");
                    SystemDictService systemDictService = (SystemDictService) SpringContextHolder.getSpringBean("SystemDictService");
@ -56,9 +56,9 @@ public class UploadThread implements Runnable {
                        Thread.sleep(retryTime);
                        continue;
                    }
                }
                Thread.sleep(1000*sleepTime);
//                }
//
//                Thread.sleep(1000*sleepTime);
            }
            catch (Exception ex)
            {

+ 2 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/SignFamilyRenewLogDao.java

@ -23,6 +23,8 @@ public interface SignFamilyRenewLogDao extends PagingAndSortingRepository<SignFa
    SignFamilyRenewLog findByProId(String proId);
    SignFamilyRenewLog findByRenewProId(String renewProId);
    
    SignFamilyRenewLog findBySignCode(String signCode);
    SignFamilyRenewLog findByRenewSignCode(String renewSignCode);

+ 50 - 1
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java

@ -6,11 +6,13 @@ import com.yihu.wlyy.sign.common.util.DateUtil;
import com.yihu.wlyy.sign.common.util.StringUtil;
import com.yihu.wlyy.sign.dao.*;
import com.yihu.wlyy.sign.entity.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -121,16 +123,62 @@ public class ChargeZYService {
                params.put("IDENTITY_CARD_NO", idcard);  //身份证
                params.put("SIGN_MANAGE_YEAR", year);  //签约年度
                params.put("SICK_NAME", patient.getName());  //姓名
                params.put("CHARGE_TIME", DateUtil.dateToStrLong(sign.getExpensesTime()));  //缴费时间
                
                if(sign.getExpensesTime() == null){
                    //如果签约表的支付时间为空,则从支付表获取支付时间
                    Date newdate = DateUtil.formatCharDateYMD(charge.getChargeTime(),"yyyyMMddHHmmss");
                    params.put("CHARGE_TIME", DateUtil.dateToStrLong(newdate));  //缴费时间
                    sign.setExpensesTime(newdate);
                    sign.setExpensesStatus("1");//已支付
                }else{
                    params.put("CHARGE_TIME", DateUtil.dateToStrLong(sign.getExpensesTime()));  //缴费时间
                }
                
               
                params.put("INSUR_PRO_ID", charge.getMiRegisterNo());  //医保签约号
                if("1".equals(sign.getRenewFlag())||"2".equals(sign.getRenewFlag())){
                    proId = signFamilyRenewLogDao.getProId(signCode);
                    if(StringUtils.isBlank(proId) || "0".equals(proId)){
                        
                        if("1".equals(sign.getSignSource())){
                            //如果是在基卫签约则需要更新同步
                            SignFamilyMapping signFamilyMapping = signFamilyMappingDao.findByCode(signCode);
                            signFamilyMapping.setNeedUpdate("1");
                            signFamilyMappingDao.save(signFamilyMapping);
                        }else{
                            //如果是网络签约则需要上传同步
                            SignFamilyRenewLog signFamilyRenewLog = signFamilyRenewLogDao.findBySignCode(signCode);
                            signFamilyRenewLog.setNeedUpload("1");
                            signFamilyRenewLogDao.save(signFamilyRenewLog);
                        }
    
                        //暂停30秒
                        Thread.sleep(30000);
                        return true;
                    }
                }else {
                    proId = signFamilyMappingDao.getProId(signCode);
                    if(StringUtils.isBlank(proId) || "0".equals(proId)){
    
                        SignFamilyMapping signFamilyMapping = signFamilyMappingDao.findByCode(signCode);
                        if("1".equals(sign.getSignSource())){
                            //如果是在基卫签约则需要更新同步
                            signFamilyMapping.setNeedUpdate("1");
                        }else{
                            //如果是网络签约则需要上传同步
                            signFamilyMapping.setNeedUpload("1");
                        }
                        signFamilyMappingDao.save(signFamilyMapping);
    
                        //暂停30秒
                        Thread.sleep(30000);
                        return true;
                    }
                }
                params.put("PRO_ID", proId);  //标志(智业签约主键)
                operator = doctorMappingDao.findByDocotrCodeAndJwDoctorHospital(operator,hm[0]);  //【医生映射】
@ -160,6 +208,7 @@ public class ChargeZYService {
                if(isSuccess)
                {
                    charge.setNeedUpload("0");
                    signFamilyDao.save(sign);
                }else {
                    charge.setNeedUpload("2");
                    content = objectMapper.writeValueAsString(charge);

+ 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);
}

+ 20 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -240,6 +240,7 @@ public class ConsultTeamService extends ConsultService {
     */
    public boolean exist(String patient, Integer type) throws Exception {
        DoctorTeamMember member = null;
        String memberCode=null;
        // 咨询三师
        if (type == 1) {
            // 查询三师签约信息
@ -256,26 +257,33 @@ public class ConsultTeamService extends ConsultService {
            if (member == null) {
                member = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
            }
            memberCode= member.getCode();
        } else if (type == 2) {
            // 咨询家庭医生
            SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
            if (sf == null) {
                throw new Exception("不存在家庭签约");
            }
            if (StringUtils.isEmpty(sf.getDoctorHealth())){
                memberCode = sf.getDoctor();
            }else {
                memberCode = sf.getDoctorHealth();
            }
            // 设置健康管理师,家庭医生咨询默认给健康管理师处理
            //查找病人所在的团队
            DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
            //得到团队的健康管理师
            member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
            if (member == null) {
                member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
            }
//            DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
//            //得到团队的健康管理师
//            member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 3);
//
//            if (member == null) {
//                member = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
//            }
        }
        if (member == null) {
            throw new Exception("找不到签约服务团队医生");
        }
        int count = consultTeamDao.countByPatient(patient, member.getMemberCode());
        int count = consultTeamDao.countByPatient(patient, memberCode);
        return count > 0;
    }
@ -1143,15 +1151,15 @@ public class ConsultTeamService extends ConsultService {
            followup.setIdcard(patientObj.getIdcard());
            
            if(3 == type){
                followup.setFollowupType("1,2");
                followup.setFollowupClass("1,2");
            }else{
                followup.setFollowupType(String.valueOf(type));
                followup.setFollowupClass(String.valueOf(type));
            }
            
            if(2 == doctor.getLevel()){//全科
                followup.setFollowupClass("22");
                followup.setFollowupType("22");
            }else if(3 == doctor.getLevel()){//健管
                followup.setFollowupClass("10");
                followup.setFollowupType("10");
            }
            followup.setDataFrom("2");//数据来源 1基卫 2APP
            followup.setStatus("2");     //状态 0取消 1已完成 2未开始 3进行中

+ 56 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/followup/FollowUpService.java

@ -1047,7 +1047,23 @@ public class FollowUpService extends BaseService {
            followupContentESDOList = result.getSourceAsObjectList(FollowupContentESDO.class);
            if (!followupContentESDOList.isEmpty()) {
                for (FollowupContentESDO followupContentESDO : followupContentESDOList) {
                    resultList.add(followupContentESDO.getFollowup_project());
                   
                    if("2".equals(followupContentESDO.getFollowup_project())){
                        //判断血压必填
                        if(StringUtils.isNotBlank(followupContentESDO.getBP_D()) && StringUtils.isNotBlank(followupContentESDO.getBP_U())){
                            resultList.add(followupContentESDO.getFollowup_project());
                        }
                    }else if("3".equals(followupContentESDO.getFollowup_project())){
                        //判断血糖必填
                        if(StringUtils.isNotBlank(followupContentESDO.getBS_FPG()) ||
                                StringUtils.isNotBlank(followupContentESDO.getNO_BS_FPG())||
                                    StringUtils.isNotBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
                            resultList.add(followupContentESDO.getFollowup_project());
                        }
                    }else{
                        resultList.add(followupContentESDO.getFollowup_project());
                    }
                    
                }
            }
@ -1146,4 +1162,43 @@ public class FollowUpService extends BaseService {
        return count;
    }
    
    /**
     * 检查随访记录是否可完成
     * @param followupid
     * @return
     */
    public boolean checkfollowupcompleted(String followupid)  throws Exception {
        boolean result = true;
    
        List<FollowupContentESDO> eslist = this.esfindFollowUpContestsByFollowupId(followupid);
    
        if (!eslist.isEmpty()) {
            for (FollowupContentESDO followupContentESDO : eslist) {
            
                if("2".equals(followupContentESDO.getFollowup_project())){
                    //判断血压必填
                    if(StringUtils.isBlank(followupContentESDO.getBP_D()) || StringUtils.isBlank(followupContentESDO.getBP_U())){
                        return false;
                    }
                }else if("3".equals(followupContentESDO.getFollowup_project())){
                    //判断血糖必填
                    if(StringUtils.isBlank(followupContentESDO.getBS_FPG()) &&
                            StringUtils.isBlank(followupContentESDO.getNO_BS_FPG()) &&
                            StringUtils.isBlank(followupContentESDO.getRANDOM_BLOOD_SUGAR())){
                        return false;
                    }
                }else if("5".equals(followupContentESDO.getFollowup_project())){
                    //判断评价
                    if(StringUtils.isBlank(followupContentESDO.getDIA_FOLLOWUP_TYPE_CODE()) &&
                            StringUtils.isBlank(followupContentESDO.getHYP_FOLLOWUP_TYPE_CODE())){
                        return false;
                    }
                }else{}
            
            }
        }
        
        return result;
    }
}

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

@ -4,6 +4,7 @@ import com.yihu.wlyy.adapter.PresModeAdapter;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.followup.Followup;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
@ -19,20 +20,25 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.ImUtill;
import org.apache.commons.collections.map.HashedMap;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -99,6 +105,12 @@ public class PrescriptionInfoService extends BaseService {
    private PrescriptionAdjustReasonDao prescriptionAdjustReasonDao;
    @Autowired
    private FollowUpDao followUpDao;
	@Value("${doctorAssistant.api}")
	private String doctorAssistant;
	@Value("${doctorAssistant.target_url}")
	private String targetUrl;
	@Autowired
	private HttpClientUtil httpClientUtil;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -495,6 +507,8 @@ public class PrescriptionInfoService extends BaseService {
        Patient p = patientDao.findByCode(patient);
        String rs = jwPrescriptionService.getRecipe(code, p.getSsc());
        com.alibaba.fastjson.JSONObject r = presModeAdapter.modelToSinglePrescription(rs);
    
        Followup followup = followUpDao.getFollowupByPrescriptionCode(code);
        String rState = presCheckStateObj(code);
        if ("1".equals(rState)) {
            r.put("reviewedState", 1);
@ -503,6 +517,7 @@ public class PrescriptionInfoService extends BaseService {
            r.put("reviewedState", 0);
            r.put("prescriptionCode", rState);
        }
        r.put("followup",followup);
        return r;
    }
@ -908,6 +923,32 @@ public class PrescriptionInfoService extends BaseService {
                //审核不通过模板消息
                sendRMess(p.getCode(), 0);
	
	            //取消长处方关联的随访记录
	            canclePrescriptionFollowup(code);
	
	            try {
		            //            新增发送医生助手模板消息 v1.4.0 by wujunjie
		            Doctor doctor = doctorDao.findByCode(p.getDoctor());
		            String doctorOpenID = doctor.getOpenid();
		            if (StringUtils.isNotEmpty(doctorOpenID)) {
			            String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
			            List<NameValuePair> params = new ArrayList<>();
			            params.add(new BasicNameValuePair("type", "1"));
			            params.add(new BasicNameValuePair("openId", doctorOpenID));
			            params.add(new BasicNameValuePair("url", targetUrl));
			            params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有一个您有1个续方申请处方开立失败。"));
			            params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
			            SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
			            String date = format.format(new Date());
			            String keywords = doctor.getName() +","+ p.getPatientName() +"," + date;
			            params.add(new BasicNameValuePair("keywords", keywords));
			
			            httpClientUtil.post(url, params, "UTF-8");
		            }
	            } catch (Exception e) {
		            e.printStackTrace();
	            }
            }
            prescriptionReviewedDao.save(reviewed);
            prescriptionDao.save(p);
@ -1850,4 +1891,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"));

+ 8 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/reply/DoctorQuickReplyService.java

@ -164,16 +164,22 @@ public class DoctorQuickReplyService extends BaseService {
     * 排序回复
     *
     * @param id
     * @param type
     * @return
     */
    public int sortReplyList(String id) {
    public int sortReplyList(String id,String type) {
        String[] ids = id.split(",");
        for (int i = 0; i < ids.length; i++) {
            DoctorQuickReply reply = quickReplyDao.findOne(Long.valueOf(ids[i]));
            if (reply == null) {
                return -1;
            }
            reply.setSort(ids.length - i);
            if("1".equals(type)){
                reply.setSort(i+1);
            }else{
                reply.setSort(ids.length - i);
            }
            
        }
        return 1;
    }

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -419,5 +419,21 @@ public class DoctorFollowUpController extends BaseController {
            return error(-1, "操作失败!");
        }
    }
    
    @RequestMapping(value = "/checkfollowupcompleted", method = RequestMethod.GET)
    @ApiOperation("检查续方关联的随访记录是否对应的详情记录")
    public String checkfollowupcompleted(
            @ApiParam(name = "followupid", value = "随访ID", defaultValue = "")
            @RequestParam(value = "followupid", required = true) String followupid){
        try {
            boolean completed = followUpService.checkfollowupcompleted(followupid);
            return write(200, "操作成功!","data",completed);
        }catch (Exception e){
            //日志文件中记录异常信息
            error(e);
            //返回接口异常信息处理结果
            return error(-1, "操作失败!");
        }
    }
}

+ 43 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java

@ -2,17 +2,29 @@ package com.yihu.wlyy.web.doctor.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.prescription.PrescriptionAdjustService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.HttpClientUtil;
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.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2017/8/17.
 */
@ -27,6 +39,14 @@ public class PrescriptionAdjustController extends BaseController {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionAdjustService prescriptionAdjustService;
    @Autowired
    private DoctorDao doctorDao;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @RequestMapping(value = "adjustPrescription",method = RequestMethod.POST)
    @ObserverRequired
@ -44,6 +64,29 @@ public class PrescriptionAdjustController extends BaseController {
            if(json.getInteger("status")==-1){
                return error(-1,json.getString("msg"));
            }
            try {
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                Prescription prescription = prescriptionDao.findByCode(code);
                Doctor doctor = doctorDao.findByCode(prescription.getDoctor());
                String doctorOpenID = doctor.getOpenid();
                if (StringUtils.isNotEmpty(doctorOpenID)) {
                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                    List<NameValuePair> params = new ArrayList<>();
                    params.add(new BasicNameValuePair("type", "9"));
                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                    params.add(new BasicNameValuePair("url", targetUrl));
                    params.add(new BasicNameValuePair("first", doctor.getName() + "医生您好。您有1个续方申请已在线下调整完成,请尽快进行CA认证."));
                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                    SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    String date = format.format(new Date());
                    String keywords = "续方审核CA认证" +"," + date;
                    params.add(new BasicNameValuePair("keywords", keywords));
                    httpClientUtil.post(url, params, "UTF-8");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            return write(200,"请求调整成功");
        }catch (Exception e){
            error(e);

+ 4 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/reply/DoctorQuickReplyController.java

@ -131,13 +131,15 @@ public class DoctorQuickReplyController extends BaseController {
    @RequestMapping(value = "/sortList", method = RequestMethod.POST)
    @ApiOperation(value = "快捷回复排序")
    public String sortReplyList(@RequestParam @ApiParam(value = "快捷回复ID")String id) {
    public String sortReplyList(@RequestParam @ApiParam(value = "快捷回复ID")String id,
                                @ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
                                @RequestParam(value = "type", required = false, defaultValue = "0") String type) {
        try {
            if (StringUtils.isEmpty(id)) {
                return error(-1, "请输入排序后的回复ID");
            }
            int result = quickReplyService.sortReplyList(id);
            int result = quickReplyService.sortReplyList(id,type);
            if (result == 1) {
                return write(200, "排序成功");

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

@ -265,15 +265,25 @@ 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));
            return write(200, "OK", "data", teamService.getAdminTeams(doctorCode));
            List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
            return write(200, "OK", "data", new JSONArray(teamList));
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/team/{doctor_code}/teamsLimit", method = RequestMethod.GET)
    @ApiOperation(value = "获取医生团队列表(获取基位签约上线)")
    public String getDoctorTeamLimit(@PathVariable("doctor_code") String doctorCode){
        try {
            return write(200, "OK", "data", teamService.getAdminTeams(doctorCode));
        }catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
    }
    @RequestMapping(value = "/team/members/{patient_code}", method = RequestMethod.GET)
    @ApiOperation(value = "根据患者代码,获取医生团队信息")
    public String getTeam(@PathVariable("patient_code") String patientCode) {

+ 55 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -803,6 +803,38 @@ public class ConsultController extends WeixinBaseController {
                        return invalidUserException(new RuntimeException(resObj.getString("message")), -1, "追问失败!" + resObj.getString("message"));
                    }
                    failed.add(String.valueOf(resObj.get("data")));
                    try {
                        //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                        Doctor doctor = doctorDao.findByCode(log.getDoctor());
                        String doctorOpenID = doctor.getOpenid();
                        if (StringUtils.isNotEmpty(doctorOpenID)) {
                                String title = "";
                                Consult consultSingle = consultDao.findByCode(log.getConsult());
                                if (consultSingle!=null){
                                    Integer singleType = consultSingle .getType();
                                    if (singleType != null && singleType ==8 ){
                                        title = consultSingle.getTitle();
                                    }else if(singleType != null && singleType !=8 ){
                                        title = consultSingle.getSymptoms();
                                    }
                                    String first = "居民" +patient.getName()+"的健康咨询有新的回复。";
                                    String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                                    List<NameValuePair> params = new ArrayList<>();
                                    params.add(new BasicNameValuePair("type", "8"));
                                    params.add(new BasicNameValuePair("openId", doctorOpenID));
                                    params.add(new BasicNameValuePair("url", targetUrl));
                                    params.add(new BasicNameValuePair("first",  first));
                                    params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                                    String keywords = title + "," + content +","+ log.getDoctorName();
                                    params.add(new BasicNameValuePair("keywords", keywords));
                                    httpClientUtil.post(url, params, "UTF-8");
                                }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            return write(200, "追问成功!", "data", failed);
@ -1067,6 +1099,29 @@ public class ConsultController extends WeixinBaseController {
            // 推送消息给医生
            pushMsgTask.put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.续方咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_PRESCRIPTION.您有新的续方咨询.name(), consult.getConsult());
            try {
                //            新增发送医生助手模板消息 v1.4.0 by wujunjie
                Doctor doctor1 = doctorDao.findByCode(doctor);
                Patient patient = patientDao.findByCode(getRepUID());
                String doctorOpenID = doctor1.getOpenid();
                if (StringUtils.isNotEmpty(doctorOpenID)) {
                        String url = doctorAssistant + "/wlyy/feldsher/sendDoctorTemplates";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("type", "9"));
                        params.add(new BasicNameValuePair("openId", doctorOpenID));
                        params.add(new BasicNameValuePair("url", targetUrl));
                        params.add(new BasicNameValuePair("first", doctor1.getName() + "医生您好。您的签约居民"+patient.getName()+"申请线上续方,请尽快审核。"));
                        params.add(new BasicNameValuePair("remark", "请进入手机APP查看"));
                        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                        String date = format.format(new Date());
                        String keywords = "续方审核" + "," + date;
                        params.add(new BasicNameValuePair("keywords", keywords));
                        httpClientUtil.post(url, params, "UTF-8");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new JSONObject(consult));
            return write(200, "提交成功", "data", consult);