Browse Source

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

yeshijie 7 years ago
parent
commit
4cadad467d

+ 3 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -27,7 +27,9 @@ public class PrescriptionLog extends IdEntity {
        pay("支付", 5),
        expressage("配送", 6),
        finish("已完成", 7),
        sf("顺丰对接", 8);
        sf("顺丰对接", 8),
        patientConfirm("居民确认收药", 9),
        jobConfirm("系统确认收药", 10);
        private String name;
        private int value;

+ 8 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PatientConfirmReceiptJob.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.physicalExamination.PatientPhysicalExaminationDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.physicalExamination.PatientPhysicalExaminationService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -54,6 +55,8 @@ public class PatientConfirmReceiptJob implements Job {
    private PatientPhysicalExaminationDao examinationDao;
    @Autowired
    private PatientPhysicalExaminationService examinationService;
    @Autowired
    private PrescriptionLogService payLogService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
@ -69,11 +72,14 @@ public class PatientConfirmReceiptJob implements Job {
                    String patient = prescription.getPatient();
                    Patient user = patientDao.findByCode(patient);
                    //2.取出延长收货的次数及支付时间
                    int extendCount = prescription.getExtendCount();
                    Integer extendCount = prescription.getExtendCount();
                    Date payTime = prescription.getPayTime();
                    if (payTime != null) {
                        //3.根据延长收货次数确定确认收货时间
                        Date today = new Date();
                        if (extendCount == null){
                            extendCount = 0;
                        }
                        Date confirm = DateUtil.getPreDays(payTime, ((extendCount + 1) * 7));
                        //4.计算现在到预计自动确认收货时间差值
                        long days = DateUtil.getDays(today,payTime);
@ -90,6 +96,7 @@ public class PatientConfirmReceiptJob implements Job {
                        if (result >= 0) {
                            prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
                            list.add(prescription);
                            payLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.jobConfirm.getValue(), 1, 0);
                            //发送自动确认提醒
                            sendWechatTemplate(2,patient,prescription.getCode());
                        }

+ 3 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionLogDao.java

@ -14,4 +14,7 @@ import java.util.List;
public interface PrescriptionLogDao extends PagingAndSortingRepository<PrescriptionLog, Long>, JpaSpecificationExecutor<PrescriptionLog> {
    @Query("select l.status,l.createTime from PrescriptionLog l where l.prescriptionCode=?1 and l.type in ?2 order by createTime desc")
    List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] types);
    @Query(" from PrescriptionLog l where l.prescriptionCode=?1 and l.status = ?2 ")
    List<PrescriptionLog> findByPrescriptionCodeAndStutas(String prescriptionCode, int status);
}

+ 6 - 6
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -859,9 +859,9 @@ public class DoctorInfoService extends BaseService {
            data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
            data.put("keyword1", newD.getName());
            if (StringUtils.isEmpty(signFamily.getDoctor()) || signFamily.getDoctorHealth().equals(signFamily.getDoctor())) {
                data.put("remark", newD.getName() + "医生将专门为您提供优质健康服务");
                data.put("remark", newD.getName() + "健管师将专门为您提供优质健康服务");
            } else {
                data.put("remark", newD.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                data.put("remark", newD.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
            }
        } else {
            data.put("toUser", patient);
@ -873,9 +873,9 @@ public class DoctorInfoService extends BaseService {
            data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
            data.put("keyword1", newD.getName());
            if (StringUtils.isEmpty(signFamily.getDoctor()) || signFamily.getDoctorHealth().equals(signFamily.getDoctor())) {
                data.put("remark", newD.getName() + "医生将专门为您提供优质的健康服务");
                data.put("remark", newD.getName() + "健管师将专门为您提供优质的健康服务");
            } else {
                data.put("remark", newD.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                data.put("remark", newD.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
            }
        }
@ -1012,9 +1012,9 @@ public class DoctorInfoService extends BaseService {
        data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
        data.put("keyword1", newD.getName());
        if (StringUtils.isEmpty(signFamily.getDoctor()) || signFamily.getDoctorHealth().equals(signFamily.getDoctor())) {
            data.put("remark", newD.getName() + "医生将专门为您提供优质的健康服务");
            data.put("remark", newD.getName() + "健管师将专门为您提供优质的健康服务");
        } else {
            data.put("remark", newD.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
            data.put("remark", newD.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
        }
        if (StringUtils.isNotBlank(p.getOpenid())) {

+ 66 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionLogService.java

@ -0,0 +1,66 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionLogDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
@Service
public class PrescriptionLogService extends BaseService {
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    /**
     * 根据处方code 和 types查询处方的流程日志 时间倒叙
     *
     * @param prescriptionCode 处方code
     * @param status           需要查询的status
     * @return
     */
    public List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] status) {
        return prescriptionLogDao.findPrescriptionLogsByPrescriptionCode(prescriptionCode, status);
    }
    /**
     * 添加日志
     *
     * @param prescription
     * @param type         类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
     * @param flag         1成功 0失败
     * @param userType     1 患者 2医生
     */
    public void addLog(Prescription prescription, Integer type, Integer flag, Integer userType) {
        PrescriptionLog log = null;
        List<PrescriptionLog> prescriptionLogs = prescriptionLogDao.findByPrescriptionCodeAndStutas(prescription.getCode(), prescription.getStatus());
        if (prescriptionLogs == null || prescriptionLogs.size() == 0) {
            log = new PrescriptionLog();
        } else {
            log = prescriptionLogDao.findOne(prescriptionLogs.get(0).getId());
        }
        log.setStatus(prescription.getStatus());
        log.setType(type);
        log.setCode(getCode());
        log.setCreateTime(new Date());
        log.setFlag(flag);
        log.setHospital(prescription.getHospital());
        log.setHospitalName(prescription.getHospitalName());
        log.setPrescriptionCode(prescription.getCode());
        if (userType == 1) {
            log.setUserCode(prescription.getParentCode());
            log.setUserName(prescription.getPatientName());
        } else {
            log.setUserCode(prescription.getDoctor());
            log.setUserName(prescription.getDoctorName());
        }
        log.setUserType(userType);
        prescriptionLogDao.save(log);
    }
}

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

@ -1827,9 +1827,9 @@ public class FamilyContractService extends BaseService {
                data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
                data.put("keyword1", docHealth.getName());
                if (StringUtils.isEmpty(signFamily.getDoctor()) || docHealth.getCode().equals(signFamily.getDoctor())) {
                    data.put("remark", docHealth.getName() + "医生将继续为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师将继续为您提供优质健康服务");
                } else {
                    data.put("remark", docHealth.getName() + "医生将继续为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师将继续为您提供优质健康服务");
                }
                wxMessages.add(data);
            } else {
@ -1843,9 +1843,9 @@ public class FamilyContractService extends BaseService {
                data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
                data.put("keyword1", docHealth.getName());
                if (StringUtils.isEmpty(signFamily.getDoctor()) || docHealth.getCode().equals(signFamily.getDoctor())) {
                    data.put("remark", docHealth.getName() + "医生将继续为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师将继续为您提供优质健康服务");
                } else {
                    data.put("remark", docHealth.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                }
                wxMessages.add(data);
                try {

+ 6 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -885,9 +885,9 @@ public class DoctorInfoService extends BaseService {
            data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
            data.put("keyword1", newD.getName());
            if (StringUtils.isEmpty(signFamily.getDoctor()) || signFamily.getDoctorHealth().equals(signFamily.getDoctor())) {
                data.put("remark", newD.getName() + "医生将专门为您提供优质健康服务");
                data.put("remark", newD.getName() + "健管师将专门为您提供优质健康服务");
            } else {
                data.put("remark", newD.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                data.put("remark", newD.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
            }
        } else {
            data.put("toUser", patient);
@ -899,9 +899,9 @@ public class DoctorInfoService extends BaseService {
            data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
            data.put("keyword1", newD.getName());
            if (StringUtils.isEmpty(signFamily.getDoctor()) || signFamily.getDoctorHealth().equals(signFamily.getDoctor())) {
                data.put("remark", newD.getName() + "医生将专门为您提供优质的健康服务");
                data.put("remark", newD.getName() + "健管师将专门为您提供优质的健康服务");
            } else {
                data.put("remark", newD.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                data.put("remark", newD.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
            }
        }
@ -1042,9 +1042,9 @@ public class DoctorInfoService extends BaseService {
        data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
        data.put("keyword1", newD.getName());
        if (StringUtils.isEmpty(signFamily.getDoctor()) || signFamily.getDoctorHealth().equals(signFamily.getDoctor())) {
            data.put("remark", newD.getName() + "医生将专门为您提供优质的健康服务");
            data.put("remark", newD.getName() + "健管师将专门为您提供优质的健康服务");
        } else {
            data.put("remark", newD.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
            data.put("remark", newD.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
        }
        if (StringUtils.isNotBlank(p.getOpenid())) {

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

@ -83,6 +83,8 @@ public class PrescriptionService extends BaseService {
    private MessageService messageService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionLogService payLogService;
    //健康问题 高血压
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
@ -119,17 +121,22 @@ public class PrescriptionService extends BaseService {
            if (type == 1){
                //直接更改状态为已完成
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
                payLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.patientConfirm.getValue(), 1, 1);
                prescription.setFinishTime(new Date());
            }else if (type == 2){
                //不更改状态只添加延长收药时间
                int extendCount = prescription.getExtendCount();
                if (extendCount>=1){
                Integer extendCount = prescription.getExtendCount();
                if (extendCount !=null && extendCount>=1){
                    result.put("code",-1);
                    result.put("msg","每笔订单只能延长一次");
                   return  result;
                }
                if (extendCount ==null){
                    prescription.setExtendCount(1);
                }else {
                    prescription.setExtendCount(prescription.getExtendCount()+1);
                }
                prescription.setExtendTime(new Date());
                prescription.setExtendCount(prescription.getExtendCount()+1);
            }
            prescriptionDao.save(prescription);
        } catch (Exception e) {
@ -640,7 +647,7 @@ public class PrescriptionService extends BaseService {
        }
        return rsMap;
    }
    
    /**
     * 根据居民CODE,时间轴,就诊类型查询用药记录
     * @param patientCode 居民CODE
@ -649,25 +656,25 @@ public class PrescriptionService extends BaseService {
     * @return
     */
    public String findPatientMedicationRecords(String patientCode, String timeline, String type) throws Exception{
        
        Integer totalCount = 0;
        
        String RECIPE_NO = "";//符合规则基卫处方医嘱号
        
        Patient patient = patientDao.findByCode(patientCode);
        
        if(patient == null){
            throw new Exception("未找到居民!");
        }
        
        String medicationRecords = "";
        
        Date timeLineDate = DateUtil.strToDateShort(timeline);
        Date startTime = DateUtil.setDateTime(timeLineDate,-25);
        Date endTime = DateUtil.setDateTime(timeLineDate,25);
        
        com.alibaba.fastjson.JSONObject re = jwPrescriptionService.getRecipeMasterList(patientCode,DateUtil.dateToStrShort(startTime),DateUtil.dateToStrShort(endTime));
        
        totalCount = re.getInteger("totalCount");
        if(totalCount>0){
            com.alibaba.fastjson.JSONArray pres = re.getJSONArray("list");
@ -677,7 +684,7 @@ public class PrescriptionService extends BaseService {
                boolean flag = false;
                for (int j = 0; j < des.size(); j++) {
                    PrescriptionDiagnosis ds = des.getObject(j, PrescriptionDiagnosis.class);
    
//                    String icdCode = ds.getHealthProblem();
//                    System.out.println(icdCode);
//                    Icd10Dict icd10Dict = icd10DictDao.findByCode(icdCode);
@ -729,13 +736,13 @@ public class PrescriptionService extends BaseService {
                }
            }
        }
        
        if(org.apache.commons.lang.StringUtils.isNotBlank(RECIPE_NO)){
            String response = jwPrescriptionService.getRecipe(RECIPE_NO,patient.getSsc());
            com.alibaba.fastjson.JSONObject jsonObject = presModeAdapter.modelToSinglePrescription(response);
            //药品
            com.alibaba.fastjson.JSONArray infos = jsonObject.getJSONArray("prescriptionInfo");
            
            for(int i=0;i<infos.size();i++){
                com.alibaba.fastjson.JSONObject info = infos.getJSONObject(i);
                String drugname =  info.getString("drugName");
@ -746,10 +753,10 @@ public class PrescriptionService extends BaseService {
                    }
                }
            }
            
        }
        
        
        return medicationRecords;
    }
}

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

@ -2342,9 +2342,9 @@ public class FamilyContractService extends BaseService {
                data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
                data.put("keyword1", docHealth.getName());
                if (StringUtils.isEmpty(signFamily.getDoctor()) || docHealth.getCode().equals(signFamily.getDoctor())) {
                    data.put("remark", docHealth.getName() + "医生将继续为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师将继续为您提供优质健康服务");
                } else {
                    data.put("remark", docHealth.getName() + "医生将继续为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师将继续为您提供优质健康服务");
                }
                wxMessages.add(data);
            } else {
@ -2358,9 +2358,9 @@ public class FamilyContractService extends BaseService {
                data.put("keyword2", DateUtil.dateToStrNoSecond(new Date()));
                data.put("keyword1", docHealth.getName());
                if (StringUtils.isEmpty(signFamily.getDoctor()) || docHealth.getCode().equals(signFamily.getDoctor())) {
                    data.put("remark", docHealth.getName() + "医生将继续为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师将继续为您提供优质健康服务");
                } else {
                    data.put("remark", docHealth.getName() + "医生与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                    data.put("remark", docHealth.getName() + "健管师与" + signFamily.getDoctorName() + "医生一道,为您提供优质健康服务");
                }
                wxMessages.add(data);
                try {