Przeglądaj źródła

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

yeshijie 7 lat temu
rodzic
commit
1262db303e

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

@ -293,6 +293,113 @@ public class PrescriptionInfoService extends BaseService {
        return new com.alibaba.fastjson.JSONArray();
        return new com.alibaba.fastjson.JSONArray();
    }
    }
    /**
     * 获取处方列表
     * @param patientCode
     * @param applyTimeFrom
     * @param applyTimeEnd
     * @param pageNo
     * @param pageSize
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject getRecipeMasterList(String patientCode,String applyTimeFrom,String applyTimeEnd,
               String isRenewal,String diagnosisCode,Integer pageNo,Integer pageSize) throws Exception{
        Patient patient = patientDao.findByCode(patientCode);
        if(pageNo==null||pageNo<=0){
            pageNo = 0;
        }
        pageNo++;
        if(pageSize==null||pageSize<=0){
            pageSize = 5;
        }
        Integer start = (pageNo-1)*pageSize;
        Integer end = pageNo*pageSize;
        Integer totalCount = 0;
        Integer newtotalCount = 0;
        com.alibaba.fastjson.JSONObject returnJson = new com.alibaba.fastjson.JSONObject();
        com.alibaba.fastjson.JSONArray filterJsonArray = new com.alibaba.fastjson.JSONArray();
        com.alibaba.fastjson.JSONObject re = jwPrescriptionService.getRecipeMasterList(patientCode,applyTimeFrom,applyTimeFrom);
        totalCount = re.getInteger("totalCount");
        if(totalCount>start){
            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);
                String rState = presCheckStateObj(r.getString("code"));
                r.put("patientName", patient.getName());
                r.put("patient", patient.getCode());
                if ("1".equals(rState)) {
                    r.put("reviewedState", 1);
                    r.put("prescriptionCode", "");
                } else {
                    r.put("reviewedState", 0);
                    r.put("prescriptionCode", rState);
                }
                com.alibaba.fastjson.JSONArray des = r.getJSONArray("prescriptionDt");
                //过滤可续签
                if (StringUtils.isNotBlank(isRenewal) && "1".equals(isRenewal)) {
                    //判断状态是否符合
                    String reviewedState = r.getString("reviewedState");
                    if ("0".equals(reviewedState)) {
                        continue;
                    }
                    boolean flag = false;
                    for (int j = 0; j < des.size(); j++) {
                        PrescriptionDiagnosis ds = des.getObject(j, PrescriptionDiagnosis.class);
                        if (gxy.equals(ds.getHealthProblem()) || tnb.equals(ds.getHealthProblem())) {
                            //为糖尿病高血压
                        } else {
                            //如果含有非糖尿病或高血压
                            flag = true;;
                        }
                    }
                    //如果未含有选择的病症,则删除
                    if (flag){
                        continue;
                    }
                }
                //过滤病症
                if(StringUtils.isNotBlank(diagnosisCode)&&!"0".equals(diagnosisCode)){
                    String dis = gxy;
                    if("1".equals(diagnosisCode)){
                        dis = gxy;
                    }else if("2".equals(diagnosisCode)){
                        dis = tnb;
                    }
                    boolean flag = false;
                    for (int j = 0; j < des.size(); j++) {
                        PrescriptionDiagnosis ds = des.getObject(j, PrescriptionDiagnosis.class);
                        //如果含有选择病症,标记为true
                        if (dis.equals(ds.getHealthProblem())) {
                            //含有选择的病症
                            flag = true;
                        }
                    }
                    //如果未含有选择的病症,则删除
                    if (!flag){
                        continue;
                    }
                }
                newtotalCount++;
                filterJsonArray.add(r);
            }
        }
        int limit = newtotalCount>end?end:newtotalCount;
        //分页处理
        com.alibaba.fastjson.JSONArray returnJsonArray = new com.alibaba.fastjson.JSONArray();
        if(newtotalCount>start){
            for (int i = start; i < limit; i++) {
                com.alibaba.fastjson.JSONObject json = filterJsonArray.getJSONObject(i);
                returnJsonArray.add(json);
            }
        }
        returnJson.put("total",newtotalCount);
        returnJson.put("list",returnJsonArray);
        return returnJson;
    }
    /**
    /**
     *
     *
     * @param code
     * @param code

+ 110 - 57
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -3,8 +3,11 @@ package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.NameValuePair;
@ -17,9 +20,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.List;
import java.util.Map;
/**
/**
 * 基位长处方接口
 * 基位长处方接口
@ -40,6 +41,10 @@ public class JwPrescriptionService {
    private PrescriptionDao prescriptionDao;
    private PrescriptionDao prescriptionDao;
    @Value("${spring.profiles}")
    @Value("${spring.profiles}")
    private String profiles;
    private String profiles;
    @Autowired
    private Icd10DictServcie icd10DictServcie;
    @Autowired
    private ZyDictService zyDictService;
    /**
    /**
     * 获取字典列表
     * 获取字典列表
@ -75,7 +80,7 @@ public class JwPrescriptionService {
    /**
    /**
     * 获取历史处方记录列表
     * 获取历史处方记录
     * @param cardNo 社保卡号
     * @param cardNo 社保卡号
     * @param recipeNo 医嘱号
     * @param recipeNo 医嘱号
     * @param applyTimeFrom 开始时间
     * @param applyTimeFrom 开始时间
@ -91,75 +96,123 @@ public class JwPrescriptionService {
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
        String response = "";
        if("prod".equals(profiles)){
            response = httpClientUtil.post(url, params, "UTF-8");
        }else {
            String sql = "SELECT h.response from wlyy_http_log h WHERE h.id = 806287";
            List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
            response = list.get(0).get("response").toString();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("status",200);
            jsonObject.put("data",response);
            response = jsonObject.toString();
        }
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
        return response;
    }
    }
    /**
    /**
     * 获取处方列表
     * 获取处方列表
     * @param cardNo
     * @param recipeNo
     * @param patientCode
     * @param applyTimeFrom
     * @param applyTimeFrom
     * @param applyTimeEnd
     * @param applyTimeEnd
     * @return
     * @return
     */
     */
    public String getRecipeList(String cardNo,String recipeNo,String applyTimeFrom,String applyTimeEnd){
        JSONObject recipeJson = new JSONObject();
        try{
            Map<String,String> map = new HashMap<>();
            JSONArray jsonArray = new JSONArray();
            for (int i=0;i<3;i++){
                if(!map.containsKey(recipeNo)){
                    map.put(recipeNo,recipeNo);
                    String response = getLastRecipe(cardNo,recipeNo,applyTimeFrom,applyTimeEnd);
                    JSONObject json = JSONObject.parseObject(response);
                    if(json.getInteger("status")==200){
                        //智业接口每次返回一条数据,需要遍历请求
                        JSONObject data = json.getJSONObject("data");
                        String code = data.getString("CODE");
                        if("1".equals(code)){
                            JSONArray returnData = data.getJSONArray("returnData");
                            if(returnData.size()>0){
                                JSONObject recipe = returnData.getJSONArray(0).getJSONObject(0);//获取最后一条处方
                                jsonArray.add(recipe);
                                recipeNo = recipe.getString("RECIPE_NO");
                                if(recipeJson.isEmpty()){
                                    recipeJson = json;
                                }else {
                                    recipeJson.getJSONObject("data").getJSONArray("returnData").getJSONArray(0).add(recipe);
                                }
    public JSONObject getRecipeMasterList(String patientCode,String applyTimeFrom,String applyTimeEnd) throws Exception{
        JSONObject re = new JSONObject();
        String url = jwUrl + "/third/prescription/getRecipeMasterList";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("patientCode", patientCode));
        params.add(new BasicNameValuePair("applyTimeFrom", applyTimeFrom));
        params.add(new BasicNameValuePair("applyTimeEnd", applyTimeEnd));
        JSONArray jsonArray = new JSONArray();
        Integer totalCount = 0;
        String errorMsg = "";
        String response = httpClientUtil.post(url, params, "UTF-8");
//        String sql = "SELECT h.response from wlyy_zy_push_log h WHERE h.id = 436";
//        List<Map<String ,Object>> list = jdbcTemplate.queryForList(sql);
//        String response = list.get(0).get("response").toString();
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("status",200);
//        jsonObject.put("data",response);
//        response = jsonObject.toString();
        JSONObject json = JSONObject.parseObject(response);
        if(json.getInteger("status")==200){
            //智业接口,需要遍历请求 实现分页
            JSONObject data = json.getJSONObject("data");
            String code = data.getString("CODE");
            if("1".equals(code)){
                JSONArray returnData = data.getJSONArray("returnData");
                JSONArray byRefParaData = data.getJSONArray("byRefParaData");
                totalCount = byRefParaData.getJSONObject(0).getInteger("totalCount");
                errorMsg = byRefParaData.getJSONObject(0).getString("errorMsg");
                if(returnData.size()>0){
                    for(int i=0;i<totalCount;i++){
                        JSONObject recipe = returnData.getJSONArray(0).getJSONObject(i);//获取最后一条处方
                        JSONObject pre = new JSONObject();
                        pre.put("code",recipe.getString("RECIPE_NO"));//医嘱号
                        pre.put("createTime",recipe.getString("APPLY_TIME"));//开单时间
//                        pre.put("applyOperator",recipe.getString("APPLY_OPERATOR"));//开单医生代码
//                        pre.put("applyOperatorName",recipe.getString("APPLY_OPERATOR_NAME"));//开单医生姓名
//                        pre.put("healthOrgCode",recipe.getString("HEALTH_ORG_CODE"));//开单机构编码
                        //开方医生和医院
                        Doctor doctor =  zyDictService.getDoctByJw(recipe.getString("APPLY_OPERATOR"),recipe.getString("HEALTH_ORG_CODE"));
                        // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                        if(doctor!=null){
                            pre.put("doctor",doctor.getCode());
                            pre.put("doctorName",doctor.getName());
                            pre.put("hospitalName",doctor.getHospitalName());
                            pre.put("hospital",doctor.getHospital());
                        }else{
                            pre.put("doctor",recipe.getString("APPLY_OPERATOR"));
                            pre.put("doctorName",recipe.getString("APPLY_OPERATOR_NAME"));
                            pre.put("hospitalName",recipe.getString("HEALTH_ORG_CODE"));
                            pre.put("hospital",recipe.getString("HEALTH_ORG_CODE"));
                        }
//                        pre.put("diagnoseCode",recipe.getString("DIAGNOSE_CODE"));//诊断代码
//                        pre.put("diagnoseName",recipe.getString("DIAGNOSE_NAME"));//诊断名称
//                        pre.put("diagnoseSubCode",recipe.getString("DIAGNOSE_SUB_CODE"));//次诊断编码
//                        pre.put("diagnoseSubName",recipe.getString("DIAGNOSE_SUB_NAME"));//次诊断名称
                        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
                        String diagnoseCode = recipe.getString("DIAGNOSE_CODE");
                        String diagnoseName = recipe.getString("DIAGNOSE_NAME");
                        diagnosis.setCode(diagnoseCode);//诊断代码
                        diagnosis.setName(diagnoseName);//诊断名称
                        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                        if(!StringUtils.isEmpty(icd10)){
                            JSONObject icd = JSONObject.parseObject(icd10);
                            diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                            diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                        }else{
                            diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                            diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                        }
                        JSONArray jsonArrayDt = new JSONArray();
                        jsonArrayDt.add(diagnosis);
                        if(recipe.getString("DIAGNOSE_SUB_CODE")!=null){
                            diagnosis = new PrescriptionDiagnosis();
                            diagnoseCode = recipe.getString("DIAGNOSE_CODE");
                            diagnoseName = recipe.getString("DIAGNOSE_NAME");
                            diagnosis.setCode(diagnoseCode);//诊断代码
                            diagnosis.setName(diagnoseName);//诊断名称
                            icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                            if(!StringUtils.isEmpty(icd10)){
                                JSONObject icd = JSONObject.parseObject(icd10);
                                diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                                diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                            }else{
                                diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                                diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                            }
                            }
                            jsonArrayDt.add(diagnosis);
                        }
                        }
                        pre.put("prescriptionDt",jsonArrayDt);
                        jsonArray.add(pre);
                    }
                    }
                }
                }
            }
            }
            if(jsonArray.size()>1){
                JSONObject re = new JSONObject();
                re.put("status",200);
                re.put("msg","调阅历史处方接口!");
                JSONObject data = new JSONObject();
                data.put("CODE","1");
                JSONArray returnData = new JSONArray();
                returnData.add(jsonArray);
                data.put("returnData",returnData);
                re.put("data",data);
                return re.toString();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        }
        return recipeJson.toString();
        re.put("list",jsonArray);
        re.put("totalCount",totalCount);
        re.put("errorMsg",errorMsg);
        return re;
    }
    }
    /**
    /**

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

@ -55,6 +55,25 @@ public class PatientPrescriptionInfoController extends BaseController {
        }
        }
    }
    }
    @RequestMapping(value = "getRecipeMasterList" , method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取智业长处方信息列表")
    public String getRecipeMasterList(@RequestParam(required = false)@ApiParam(name="isRenewal",value="处方是否可续方:1.是;2.无过滤")String isRenewal,
                                      @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                      @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                      @RequestParam(required = false,defaultValue = "0")@ApiParam(name="diagnosisCode",value="所有诊断(0 全部 1高血压 2糖尿病)")String diagnosisCode,
                                      @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                      @RequestParam(required = false)@ApiParam(name="size",value="每页记录数")Integer size){
        try {
//            com.alibaba.fastjson.JSONObject json = prescriptionInfoService.getRecipeMasterList("ec7572875d27446cb4f067b13a85d72a",startDate,endDate,isRenewal,diagnosisCode,page,size);
            com.alibaba.fastjson.JSONObject json = prescriptionInfoService.getRecipeMasterList(getRepUID(),startDate,endDate,isRenewal,diagnosisCode,page,size);
            return write(200, "查询成功!", "data",json);
        }catch (Exception e){
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPrescription" ,method = RequestMethod.GET)
    @RequestMapping(value = "/getPrescription" ,method = RequestMethod.GET)
    @ResponseBody
    @ResponseBody
    @ApiOperation(value = "获取长处方详细信息")
    @ApiOperation(value = "获取长处方详细信息")