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

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

chenweida 7 роки тому
батько
коміт
43385396b5

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

@ -404,12 +404,12 @@ public class Prescription extends IdEntity {
         wait_pay("开方完成/待支付", 20),
         pay_error("支付失败", 21),
         pay_success("支付成功/待配药", 30),
         wait_expressage("配药成功/待配送", 40),
         expressageing_error("配送失败", 41),
         expressageJGS("分配健管师", 42),
         expressageing("配送中", 45),
         pay_success("支付成功/待配药", 50),
         expressage2hospital("配送到服务站", 49),
         finish("配送到患者手中/已完成", 100);
         */

+ 1 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -922,6 +922,7 @@ public class DeviceService {
                contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
                contentPatient.put("needUpload","false");
                contentPatient.put("healthindexid",result.getId());//体征记录 ID
            
                //患者发送Im消息
                ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);

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

@ -341,7 +341,13 @@ public class PrescriptionService extends ZysoftBaseService{
                Prescription prescription = prescriptionDao.findByVisitNoAndRecipeNo(orderNo,recipeNo);
                if(prescription.getStatus().equals(PrescriptionLog.PrescriptionLogStatus.pay_success.getValue())){
                    prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
                    
                    if(2 == prescription.getDispensaryType()){//如果是快递配送,则直接修改成配送中
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
                    } else{
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
                    }
                    
                    prescription.setDrugDeliveryTime(new Date());
                    prescriptionDao.save(prescription);
@ -356,44 +362,51 @@ public class PrescriptionService extends ZysoftBaseService{
                    log.setHospitalName(prescription.getHospitalName());
                    log.setUserName(prescription.getDoctorName());
                    log.setFlag(1);
                    log.setRemark("配药成功");
                    log.setUserCode(prescription.getDoctor());
                    log.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
                    prescriptionLogDao.save(log);
                    //健管师配送
                    PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(prescription.getCode());
                    if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                        Message message = new Message();
                        message.setCzrq(new Date());
                        message.setCreateTime(new Date());
                        message.setRead(1);//设置未读
                        message.setOver("1");
                        message.setReceiver(expressage.getExpressageCode());
                        message.setSender("system");
                        message.setCode(getCode());
                        message.setSenderName("系统");
                        message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                        message.setContent("您有一条新的续方订单待取药!");
                        message.setType(7);//续方订单待取药
                        message.setReadonly(1);//是否只读消息
                        message.setDel("1");
                        message.setRelationCode(prescription.getCode());
                        message.setPrescriptionStatus("0");//待取药
                        message.setData(prescription.getAdminTeamId()+"");
                        messageDao.save(message);
                    }
                    //判断提示健管师有续方代配送,居民待取药
                    JSONObject message = new JSONObject();
                    message.put("title","dispensingComplete");
                    message.put("state",1);
                    message.put("prescription",prescription.getCode());
                    message.put("mes","success");
                    if(2 == prescription.getDispensaryType()){//如果是快递配送,则直接修改成配送中
                        log.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
                        log.setRemark("快递配送:配药成功,配送中");
                        prescriptionLogDao.save(log);
                    } else{
                        log.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue());
                        log.setRemark("配药成功");
                        prescriptionLogDao.save(log);
    
                        //健管师配送
                        PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(prescription.getCode());
                        if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                            Message message = new Message();
                            message.setCzrq(new Date());
                            message.setCreateTime(new Date());
                            message.setRead(1);//设置未读
                            message.setOver("1");
                            message.setReceiver(expressage.getExpressageCode());
                            message.setSender("system");
                            message.setCode(getCode());
                            message.setSenderName("系统");
                            message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                            message.setContent("您有一条新的续方订单待取药!");
                            message.setType(7);//续方订单待取药
                            message.setReadonly(1);//是否只读消息
                            message.setDel("1");
                            message.setRelationCode(prescription.getCode());
                            message.setPrescriptionStatus("0");//待取药
                            message.setData(prescription.getAdminTeamId()+"");
                            messageDao.save(message);
                        }
    
                        //判断提示健管师有续方代配送,居民待取药
                        JSONObject message = new JSONObject();
                        message.put("title","dispensingComplete");
                        message.put("state",1);
                        message.put("prescription",prescription.getCode());
                        message.put("mes","success");
//                redisTemplate.convertAndSend(channelTopic,message.toString());
//                redisTemplate.watch(channelTopic);
                    redisTemplate.opsForList().leftPush(channelTopic,message.toString());
                        redisTemplate.opsForList().leftPush(channelTopic,message.toString());
//                redisTemplate.unwatch();
                    }
                }else {
                    error = "code:"+prescription.getCode()+",status:"+prescription.getStatus();
                }

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java

@ -16,7 +16,7 @@ public interface PrescriptionExpressageDao extends PagingAndSortingRepository<Pr
    @Query("from PrescriptionExpressage p where p.prescriptionCode=?1")
    PrescriptionExpressage findByPrescriptionPay(String prescriptionCode);
    @Query(value = "select p.* FROM wlyy_prescription_expressage p LEFT JOIN wlyy_prescription a on a.code = p.prescription_code where a.status = 30 and p.mobile is null",nativeQuery = true)
    @Query(value = "select p.* FROM wlyy_prescription_expressage p LEFT JOIN wlyy_prescription a on a.code = p.prescription_code where a.status >= 50 and p.mobile is null",nativeQuery = true)
    List<PrescriptionExpressage> findByPrescriptionPaidExpressOrderFail();
    @Query("from PrescriptionExpressage p where p.mailno=?1")

+ 9 - 11
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -42,26 +42,24 @@ public class PrescriptionExpressageService {
    /**
     * 1,保存快递单号增
     * 2,加处方物流记录为配送
     * 3,修改处方状态为配送配送中
     *
     * @param prescriptionExpressage
     * @throws Exception
     */
    public void updatePrescriptionExpressage(PrescriptionExpressage prescriptionExpressage) throws Exception {
        //修改处方状态为配送配送中
        prescriptionDao.updateStatus(prescriptionExpressage.getPrescriptionCode(),65);
//        prescriptionDao.updateStatus(prescriptionExpressage.getPrescriptionCode(),65);
        //保存处方物流记录
        prescriptionExpressageDao.save(prescriptionExpressage);
        //保存配送日志
        PrescriptionLog prescriptionLog = new PrescriptionLog();
        prescriptionLog.setPrescriptionCode(prescriptionExpressage.getPrescriptionCode());
        prescriptionLog.setCode(UUID.randomUUID().toString());
        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.sf.getValue());
        prescriptionLog.setCreateTime(new Date());
        prescriptionLog.setFlag(1);
        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
        prescriptionLogDao.save(prescriptionLog);
//        PrescriptionLog prescriptionLog = new PrescriptionLog();
//        prescriptionLog.setPrescriptionCode(prescriptionExpressage.getPrescriptionCode());
//        prescriptionLog.setCode(UUID.randomUUID().toString());
//        prescriptionLog.setType(PrescriptionLog.PrescriptionLogType.sf.getValue());
//        prescriptionLog.setCreateTime(new Date());
//        prescriptionLog.setFlag(1);
//        prescriptionLog.setStatus(PrescriptionLog.PrescriptionLogStatus.expressageing.getValue());
//        prescriptionLogDao.save(prescriptionLog);
    }
}

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -624,42 +624,49 @@ public class PatientHealthIndexService extends BaseService {
                        obj.put("value1", data);
                        obj.put("time1", recordDate);
                        obj.put("id1", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn1", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("2")) {
                        obj.put("value2", data);
                        obj.put("time2", recordDate);
                        obj.put("id2", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn2", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("3")) {
                        obj.put("value3", data);
                        obj.put("time3", recordDate);
                        obj.put("id3", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn3", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("4")) {
                        obj.put("value4", data);
                        obj.put("time4", recordDate);
                        obj.put("id4", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn4", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("5")) {
                        obj.put("value5", data);
                        obj.put("time5", recordDate);
                        obj.put("id5", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn5", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("6")) {
                        obj.put("value6", data);
                        obj.put("time6", recordDate);
                        obj.put("id6", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn6", deviceSn);
                        hadData = true;
                    } else if (dataType.equals("7")) {
                        obj.put("value7", data);
                        obj.put("time7", recordDate);
                        obj.put("id7", id);
                        obj.put("healthindexid", id);
                        obj.put("deviceSn7", deviceSn);
                        hadData = true;
                    }
@ -934,6 +941,7 @@ public class PatientHealthIndexService extends BaseService {
                contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
                contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
                contentPatient.put("needUpload","false");
                contentPatient.put("healthindexid",result.getId());//体征记录 ID
                
                //患者发送Im消息
                ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);
@ -1204,6 +1212,7 @@ public class PatientHealthIndexService extends BaseService {
            for (Map<String, Object> map : list) {
                JSONObject json = new JSONObject();
                json.put("id", map.get("id"));
                json.put("healthindexid", map.get("id"));
                json.put("patient", map.get("user"));
                json.put("value1", map.get("value1"));
                json.put("value2", map.get("value2"));

+ 53 - 24
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionFollowupContentService.java

@ -200,6 +200,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			jsonObject1.put("statue","2");//1已填写,2未填写
			jsonObject1.put("createtime","");
		}
		jsonObject1.put("typevalue","1");
		result.add(jsonObject1);
		
		JSONObject jsonObject2 = new JSONObject();
@ -214,6 +215,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			jsonObject2.put("statue","2");//1已填写,2未填写
			jsonObject2.put("createtime","");
		}
		jsonObject2.put("typevalue","2,4");
		result.add(jsonObject2);
		
		return result;
@ -300,9 +302,12 @@ public class PrescriptionFollowupContentService extends BaseService {
		String sql = "select sum(category_code) amount FROM wlyy_patient_device WHERE user='"+prescription.getPatient()+"'";
		List<Map<String,Object>> result =  jdbcTemplate.queryForList(sql);
		if (result != null && result.size() > 0) {
			total = (result.get(0).get("amount") != null ? Integer.parseInt(result.get(0).get("amount").toString()) : 0);
			if(result.get(0).get("amount") != null){
				Double amount = new Double(result.get(0).get("amount").toString());
				total = (result.get(0).get("amount") != null ? amount.intValue() : 0);
			}
		}
		if(total != 1 || total != 3){
		if(total != 1 && total !=3){
			contentDoctor.put("deviceMsg","您未绑定血糖智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
		}
		
@ -364,7 +369,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			
			FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectData(followup_id,"3");
			
			if(followupContentESDO != null){
			if(followupContentESDO == null){
				followUpService.esSaveFollowupProjectData(followup_id, "3", followupProjectData);
			}else{
				FollowupContentESDO newfollowupContentESDO = JSON.parseObject(followupProjectData, FollowupContentESDO.class);
@ -401,6 +406,8 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
				contentPatient.put("needUpload","false");
				contentPatient.put("type",2);
				contentPatient.put("healthindexid",obj.getString("healthindexid"));
				
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
@ -421,6 +428,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("tzMsg", "体征记录:无");
				contentPatient.put("tzTime", "检测时间:");
				contentPatient.put("tzAlert","温馨提示:居民近30天未上传血糖体征数据,已通知居民上传数据,请耐心等待");
				contentPatient.put("patientAlert","温馨提示:您近30天未上传血糖体征数据,您可以");
				contentPatient.put("needUpload","true");
				contentPatient.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
				contentPatient.put("type",2);
@ -466,7 +474,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			
			if(devicePatientHealthIndex != null){
				org.json.JSONObject json = new org.json.JSONObject();
				json.put("id", devicePatientHealthIndex.getId());
				json.put("healthindexid", devicePatientHealthIndex.getId());
				json.put("patient",devicePatientHealthIndex.getUser());
				json.put("value1", devicePatientHealthIndex.getValue1());
				json.put("value2", devicePatientHealthIndex.getValue2());
@ -501,9 +509,12 @@ public class PrescriptionFollowupContentService extends BaseService {
		String sql = "select sum(category_code) amount FROM wlyy_patient_device WHERE user='"+prescription.getPatient()+"'";
		List<Map<String,Object>> result =  jdbcTemplate.queryForList(sql);
		if (result != null && result.size() > 0) {
			total = (result.get(0).get("amount") != null ? Integer.parseInt(result.get(0).get("amount").toString()) : 0);
			if(result.get(0).get("amount") != null){
				Double amount = new Double(result.get(0).get("amount").toString());
				total = (result.get(0).get("amount") != null ? amount.intValue() : 0);
			}
		}
		if(total != 2 || total != 3){
		if(total != 2 && total !=3 ){
			contentDoctor.put("deviceMsg","您未绑定血压智能设备,请手动上传体征数据,绑定设备后系统将会自动将您的体征数据上报给医生");
		}
		
@ -516,7 +527,7 @@ public class PrescriptionFollowupContentService extends BaseService {
			
			FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectData(followup_id,"2");
			
			if(followupContentESDO != null){
			if(followupContentESDO == null){
				followUpService.esSaveFollowupProjectData(followup_id, "2", followupProjectData);
			}else{
				followupContentESDO.setBP_D(jsonObject.getString("value1"));
@ -544,6 +555,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("needUpload","false");
				contentPatient.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
				contentPatient.put("type",1);
				contentPatient.put("healthindexid",jsonObject.get("healthindexid"));
				
				//患者发送Im消息
				ImUtill.sendTopicIM(prescription.getPatient(), prescription.getPatientName(), prescription.getConsult(), "16", contentPatient.toString(), null);
@ -565,6 +577,7 @@ public class PrescriptionFollowupContentService extends BaseService {
				contentPatient.put("tzMsg", "体征记录:无");
				contentPatient.put("tzTime", "检测时间:");
				contentPatient.put("tzAlert","温馨提示:居民近30天未上传血压体征数据,已通知居民上传数据,请耐心等待");
				contentPatient.put("patientAlert","温馨提示:您近30天未上传血压体征数据,您可以");
				contentPatient.put("needUpload","true");
				contentPatient.put("isSendWxTemplate",false);//是否发送咨询回复的微信模板
				contentPatient.put("type",1);
@ -615,38 +628,54 @@ public class PrescriptionFollowupContentService extends BaseService {
		}else if("2".equals(type)){
			//2体征
			Map<String, String> datamap2 = new HashMap<>();
			
			List<PrescriptionFollowupContent>  list2 = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,"2");
			
			if(!list2.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list2) {
					datamap2.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
					if(StringUtils.isNotBlank(prescriptionFollowupContent.getFollowupValue())){
						datamap2.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
					}
				}
			}
			//近30天血压
			String stardate = DateUtil.getNextMonth(new Date(),-1)+" 00:00:00";
			String enddate = DateUtil.getStringDateShort()+" 23:59:59";
			org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
			if(jsonArray.length() > 0){
				org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
				datamap2.put("BP_D",jsonObject.getString("value1"));
				datamap2.put("BP_U",jsonObject.getString("value2"));
			}
			followUpService.esSaveFollowupProjectData(followup_id, "2", JSON.toJSONString(datamap2));
			
			//判断随访中是否已经有体征的相关数据
			FollowupContentESDO followupContentESDO = followUpService.esGetFollowupProjectData(followup_id,"2");
			if(followupContentESDO == null){
				//如果没有,则自动获取近30天的血压
				//近30天血压
				String stardate = DateUtil.getNextMonth(new Date(),-1)+" 00:00:00";
				String enddate = DateUtil.getStringDateShort()+" 23:59:59";
				org.json.JSONArray jsonArray = healthIndexService.findIndexByPatient(patientCode, 2, stardate, enddate, 0, 2);
				if(jsonArray.length() > 0){
					org.json.JSONObject jsonObject = jsonArray.getJSONObject(0);
					datamap2.put("BP_D",jsonObject.getString("value1"));
					datamap2.put("BP_U",jsonObject.getString("value2"));
				}
			}else{
				datamap2.put("BP_D",followupContentESDO.getBP_D());
				datamap2.put("BP_U",followupContentESDO.getBP_U());
			}
			//保存随访体征数据
			if(!datamap2.isEmpty()){
				followUpService.esSaveFollowupProjectData(followup_id, "2", JSON.toJSONString(datamap2));
			}
			
			Map<String, String> datamap3 = new HashMap<>();
			List<PrescriptionFollowupContent>  list3 = prescriptionFollowupContentDao.findByPrescriptionCodeAndFollowupProject(prescriptioncode,"4");
			
			if(!list3.isEmpty()){
				for (PrescriptionFollowupContent prescriptionFollowupContent: list3) {
					datamap3.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
					if(StringUtils.isNotBlank(prescriptionFollowupContent.getFollowupValue())){
						datamap3.put(prescriptionFollowupContent.getFollowupKey(),prescriptionFollowupContent.getFollowupValue());
					}
				}
			}
			followUpService.esSaveFollowupProjectData(followup_id, "4", JSON.toJSONString(datamap3));
		
			
			//保证生活方式
			if(!datamap3.isEmpty()){
				followUpService.esSaveFollowupProjectData(followup_id, "4", JSON.toJSONString(datamap3));
			}
		}else{}
	}