瀏覽代碼

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

huangwenjie 7 年之前
父節點
當前提交
1269d93f56

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

@ -3,14 +3,18 @@ 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.dict.Icd10Dict;
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 +28,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;
@ -86,6 +91,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 +644,113 @@ 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, Integer 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 (1 == type) {
                        //主诊断为糖尿病
                        if(tnb.equals(ds.getHealthProblem())){
                            RECIPE_NO = r.getString("code");
                            break;
                        }else{
                            continue;
                        }
                    } else  if(2 == 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;
    }
}

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

@ -3,6 +3,8 @@ 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.service.third.iot.IotDeviceService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -27,6 +29,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 +212,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)Integer type){
        try {
            return write(200,"查询成功","data",prescriptionService.findPatientMedicationRecords(patientCode,timeline,type));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}