Quellcode durchsuchen

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

trick9191 vor 7 Jahren
Ursprung
Commit
0161e6d756

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml

@ -111,7 +111,7 @@ express:
activemq:
  username: jkzl
  password: jkzlehr
  url: tcp://192.168.120.153:61616
  url: tcp://59.61.92.90:9103
  queue:
    healtHarticleQueue: healthArticleChannel  #健康文章推送
  consumers:

+ 50 - 17
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -5,7 +5,6 @@ import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientBloodSugger;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.device.PatientHealthTime;
import com.yihu.wlyy.entity.dict.Icd10Dict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
@ -23,7 +22,9 @@ import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.third.iot.IotDeviceService;
import com.yihu.wlyy.service.third.jw.JwSmjkService;
import com.yihu.wlyy.util.DateUtil;
@ -59,7 +60,8 @@ public class PatientDeviceService extends BaseService {
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private Icd10DictServcie icd10DictServcie;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
@ -87,7 +89,8 @@ public class PatientDeviceService extends BaseService {
    private PatientHealthStandardDao patientHealthStandardDao;
    @Autowired
    private HttpClientUtil HttpClientUtil;
    @Autowired
    private PrescriptionService prescriptionService;
    @Value("${yihu.yihu_OpenPlatform_url}")
    private String url;
    @Value("${yihu.yihu_OpenPlatform_appId}")
@ -107,7 +110,10 @@ public class PatientDeviceService extends BaseService {
    private IotDeviceService iotDeviceService;
    @Autowired
    private Icd10DictDao icd10DictDao;
    //健康问题 高血压
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
    private static final String tnb = "HP0047";
    Map<Integer, String> relations = new HashMap<>();
    @PostConstruct
@ -932,6 +938,9 @@ public class PatientDeviceService extends BaseService {
        int eventSize = 0;//就诊次数
        int times = 0;//住院次数
        int num = 10;//查找10次后就不找了。
        int ni = 0;
        String drugs = "";
        if (!StringUtils.isEmpty(response)) {
            JSONArray array = new JSONArray(response);
            if (!"[{}]".equals(response)) {
@ -949,22 +958,45 @@ public class PatientDeviceService extends BaseService {
                    if(StringUtils.isNotBlank(type)){
                        //根据icd10过滤数据
                        String icdCode = item.optString("ICD_CODE");
                        Icd10Dict icd10Dict = icd10DictDao.findByCode(icdCode);
                        if(icd10Dict==null){
                            continue;
                        }
                        if("1".equals(type)){
                            //血糖
                            if(!"2".equals(icd10Dict.getType())){
                                continue;
                        String icdCode = item.optString("DIAGNOSIS");
                        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(icdCode);
                        if(StringUtils.isNotBlank(icd10)){
                            com.alibaba.fastjson.JSONObject icd = com.alibaba.fastjson.JSONObject.parseObject(icd10);
                            String key = icd.getString("key");
                            if ("1".equals(type)) {
                                //主诊断为糖尿病
                                if(!tnb.equals(key)){
                                    continue;
                                }
                            } else  if("2".equals(type)){
                                //主诊断为高血压
                                if(!gxy.equals(key)){
                                    continue;
                                }
                            }
                        }else {
                            //血压
                            if(!"1".equals(icd10Dict.getType())){
                                continue;
                            }
                            continue;
                        }
//                        Icd10Dict icd10Dict = icd10DictDao.findByCode(icdCode);
//                        if(icd10Dict==null){
//                            continue;
//                        }
//                        if("1".equals(type)){
//                            //血糖
//                            if(!"2".equals(icd10Dict.getType())){
//                                continue;
//                            }
//                        }else {
//                            //血压
//                            if(!"1".equals(icd10Dict.getType())){
//                                continue;
//                            }
//                        }
                        ni++;
                        if(ni<num&&StringUtils.isEmpty(drugs)){
                            drugs = prescriptionService.findPatientMedicationRecords(patientCode,item.optString("END_TIME").toString(),type);
                        }
                    }
                    if("2".equals(item.optString("TYPE"))){
                        times++;
@ -1006,6 +1038,7 @@ public class PatientDeviceService extends BaseService {
        statistics.put("times",times);
        json.put("statistics",statistics);
        json.put("list",re);
        json.put("drugs",drugs);
        return json;
    }

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

@ -1210,7 +1210,7 @@ public class PatientHealthIndexService extends BaseService {
     * 按时间段查询患者健康指标
     *
     * @param type    健康指标类型(1血糖,2血压,3体重,4腰围)
     * @param gi_type 血糖就餐时间段(早餐前,早餐后等),(type=2时,1表示收缩压、2表示舒张压)
     * @param gi_type 血糖就餐时间段(早餐前,早餐后等)
     * @param begin   开始时间
     * @param end     结束时间
     * @return
@ -1336,40 +1336,36 @@ public class PatientHealthIndexService extends BaseService {
                Double minValueSSY = SystemConf.HEALTH_STANDARD_SSY_MIN;
                Double maxValueSZY = SystemConf.HEALTH_STANDARD_SZY_MAX;
                Double minValueSZY = SystemConf.HEALTH_STANDARD_SZY_MIN;
                if(gi_type==1){
                    //1表示收缩压
                    returnInt = checkHealth(maxValueSSY,minValueSSY,intVlue1);
                    switch (returnInt){
                        case 0:
                            normal++;
                            break;
                        case 1:
                            high++;
                            break;
                        default:
                            low++;
                            break;
                    }
                    if(intVlue1>=maxValueSSY){
                        flag = true;
                    }
                }else if(gi_type==2){
                    //2表示舒张压
                    returnInt = checkHealth(maxValueSZY,minValueSZY,intVlue2);
                    switch (returnInt){
                        case 0:
                            normal++;
                            break;
                        case 1:
                            high++;
                            break;
                        default:
                            low++;
                            break;
                    }
                    if(intVlue2>=maxValueSSY){
                        flag = true;
                    }
                returnInt = checkHealth(maxValueSSY,minValueSSY,intVlue1);
                switch (returnInt){
                    case 0:
                        normal++;
                        break;
                    case 1:
                        high++;
                        if(intVlue1>=maxValueSSY){
                            flag = true;
                        }
                        break;
                    default:
                        low++;
                        break;
                }
                returnInt = checkHealth(maxValueSZY,minValueSZY,intVlue2);
                switch (returnInt){
                    case 0:
                        normal++;
                        break;
                    case 1:
                        high++;
                        if(intVlue2>=maxValueSSY){
                            flag = true;
                        }
                        break;
                    default:
                        low++;
                        break;
                }
            }
@ -1413,7 +1409,7 @@ public class PatientHealthIndexService extends BaseService {
     * @return -1偏低,0正常,1偏高
     */
    private Integer checkHealth(Double max,Double min,Double value){
        if(max<=value){
        if(max<value){
            return 1;
        }else if(min>value){
            return -1;

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

@ -3,14 +3,17 @@ package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.adapter.PresModeAdapter;
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.message.MessageNoticeSetting;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
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.dict.Icd10DictDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.followup.FollowUpDao;
import com.yihu.wlyy.repository.message.MessageDao;
@ -24,6 +27,7 @@ import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
@ -38,7 +42,6 @@ import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
@ -86,6 +89,10 @@ public class PrescriptionService extends BaseService {
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
    private static final String tnb = "HP0047";
    @Autowired
    private PresModeAdapter presModeAdapter;
    @Autowired
    private Icd10DictDao icd10DictDao;
    /**
     *  获取处方信息
@ -635,4 +642,116 @@ public class PrescriptionService extends BaseService {
        }
        return rsMap;
    }
    
    /**
     * 根据居民CODE,时间轴,就诊类型查询用药记录
     * @param patientCode 居民CODE
     * @param timeline 时间轴(根据传入的时间搜索前25天后25天)YYYY-MM-DD
     * @param type 1糖尿病,2高血压
     * @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");
            for (int i = 0; i < pres.size(); i++) {
                com.alibaba.fastjson.JSONObject r = (com.alibaba.fastjson.JSONObject) pres.get(i);
                com.alibaba.fastjson.JSONArray des = r.getJSONArray("prescriptionDt");
                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);
//                    if(icd10Dict==null){
//                        continue;
//                    }
//
//                    System.out.println(r.getString("code"));
//                    if("1".equals(type)){
//                        //血糖
//                        if(!"2".equals(icd10Dict.getType())){
//                            continue;
//                        }else{
//                            RECIPE_NO = r.getString("code");
//                            break;
//                        }
//                    }else {
//                        //血压
//                        if(!"1".equals(icd10Dict.getType())){
//                            continue;
//                        }else{
//                            RECIPE_NO = r.getString("code");
//                            break;
//                        }
//                    }
                    if(type==null){
                        RECIPE_NO = r.getString("code");
                        break;
                    }
                    if ("1".equals(type)) {
                        //主诊断为糖尿病
                        if(tnb.equals(ds.getHealthProblem())){
                            RECIPE_NO = r.getString("code");
                            break;
                        }else{
                            continue;
                        }
                    } else  if("2".equals(type)){
                        //主诊断为高血压
                        if(gxy.equals(ds.getHealthProblem())){
                            RECIPE_NO = r.getString("code");
                            break;
                        }else{
                            continue;
                        }
                    }else{
                        continue;
                    }
                }
            }
        }
        
        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");
                if(org.apache.commons.lang.StringUtils.isNotBlank(drugname)){
                    medicationRecords = medicationRecords + drugname;
                    if(i != (infos.size() -1)){
                        medicationRecords = medicationRecords + ",";
                    }
                }
            }
            
        }
        
        
        return medicationRecords;
    }
}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/iot/IotMonitoringHealthController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.third.gateway.controller.iot;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,6 +28,8 @@ public class IotMonitoringHealthController extends BaseController {
    private PatientDeviceService patientDeviceService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    @Autowired
    private PrescriptionService prescriptionService;
    @RequestMapping(value = "/equipmentDistribution",method = RequestMethod.GET)
    @ApiOperation("设备发放情况")
@ -208,5 +211,21 @@ public class IotMonitoringHealthController extends BaseController {
            }
        }
    }
    
    @RequestMapping(value = "findPatientMedicationRecords",method = RequestMethod.GET)
    @ApiOperation("根据居民CODE,时间轴,就诊类型查询用药记录")
    public String findPatientMedicationRecords(@ApiParam(name="patientCode",value = "居民code",defaultValue = "ed57f0d34e11458db8540bb8c942ff4f")
                                               @RequestParam(name="patientCode",required = true)String patientCode,
                                               @ApiParam(name="timeline",value = "时间轴(根据传入的时间搜索前25天后25天)YYYY-MM-DD")
                                               @RequestParam(name="timeline",required = true)String timeline,
                                               @ApiParam(name="type",value = "1糖尿病,2高血压")
                                               @RequestParam(name="type",required = true)String type){
        try {
            return write(200,"查询成功","data",prescriptionService.findPatientMedicationRecords(patientCode,timeline,type));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -127,7 +127,7 @@ jkEdu:
activemq:
  username: admin
  password: admin
  url: tcp://172.19.103.87:61616
  url: tcp://10.95.22.168:61616
  queue:
    healtHarticleQueue: healthArticleChannel_devtest  #健康文章推送

+ 1 - 1
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -133,7 +133,7 @@ jkEdu:
activemq:
  username: jkzl
  password: jkzlehr
  url: tcp://192.168.120.153:61616
  url: tcp://59.61.92.90:9103
  queue:
    healtHarticleQueue: healthArticleChannel  #健康文章推送