Browse Source

修改肾小球计算公式接口

hujing 6 years ago
parent
commit
f87a61b05f

+ 212 - 199
graph-web/src/main/java/org/diagbot/graphWeb/work/GraphCalculate.java

@@ -21,8 +21,10 @@ import org.slf4j.LoggerFactory;
 
 public class GraphCalculate {
     Logger logger = LoggerFactory.getLogger(GraphCalculate.class);
+
     /**
      * 返回诊断和治疗
+     *
      * @param request
      * @param searchData
      * @return
@@ -30,21 +32,21 @@ public class GraphCalculate {
      */
     public ResponseData calculate(HttpServletRequest request, SearchData searchData) throws Exception {
         ResponseData responseData = new ResponseData();
-//        ParamsDataProxy paramsDataProxy = new ParamsDataProxy();
-//        paramsDataProxy.createSearchData(request,searchData);
+        ParamsDataProxy paramsDataProxy = new ParamsDataProxy();
+        paramsDataProxy.createSearchData(request, searchData);
         List<String> inputList = new ArrayList<>();
         Map<String, Map<String, String>> inputs = searchData.getInputs();
         Set<String> ss = inputs.keySet();
-        logger.info("从分词系统接收到的词 :"+ss);
+        logger.info("从分词系统接收到的词 :" + ss);
         inputList.addAll(ss);
         Neo4jAPI neo4jAPI = new Neo4jAPI(DriverManager.newDrive());
         logger.info("图谱开始推送诊断!!!!!!!!!!!");
         //计算诊断
         Map<String, String> condition = neo4jAPI.getCondition((String[]) inputList.toArray(new String[inputList.size()]));
         List<FeatureRate> featureRates = new ArrayList<>();
-        for (Map.Entry<String,String> d:condition.entrySet()) {
-            if(!"低血糖反应".equals(d.getKey()) && !"胃肠道不良反应".equals(d.getKey())
-                    && !"肾功能不全".equals(d.getKey())){
+        for (Map.Entry<String, String> d : condition.entrySet()) {
+            if (!"低血糖反应".equals(d.getKey()) && !"胃肠道不良反应".equals(d.getKey())
+                    && !"肾功能不全".equals(d.getKey())) {
                 FeatureRate featureRate = new FeatureRate();
                 featureRate.setFeatureName(d.getKey());
                 featureRate.setExtraProperty("");
@@ -57,25 +59,25 @@ public class GraphCalculate {
         Set<String> diseaseSet = condition.keySet();
         String[] featureTypes = searchData.getFeatureType().split(",");
         List<String> featureTypeList = Arrays.asList(featureTypes);
-        logger.info("featureTypeList : "+featureTypeList);
-        logger.info("diseaseSet :"+diseaseSet);
+        logger.info("featureTypeList : " + featureTypeList);
+        logger.info("diseaseSet :" + diseaseSet);
         Integer diseaseType = searchData.getDisType();
         //走治疗
-        if(webDiag.trim()!=null && webDiag.trim()!="" && featureTypeList.contains("8")){
+        if (webDiag.trim() != null && webDiag.trim() != "" && featureTypeList.contains("8")) {
             //走平常诊断治疗
-            Map<String, Filnlly> mulDiseaseTreat = neo4jAPI.getMulDiseaseTreat_2(webDiag,diseaseType,diseaseSet,String.join(",", inputList));
+            Map<String, Filnlly> mulDiseaseTreat = neo4jAPI.getMulDiseaseTreat_2(webDiag, diseaseType, diseaseSet, String.join(",", inputList));
             responseData.setTreat(mulDiseaseTreat);
         }
         //管理评估(慢病才有)
-        if(featureTypeList.contains("11") && diseaseType == 1 && diseaseType !=null){
+        if (featureTypeList.contains("11") && diseaseType == 1 && diseaseType != null) {
             logger.info("featureTypeList 包含11,走管理评估!!!");
             MangementEvaluation mangementEvaluation = this.getMangementEvaluation();
             Map<String, JSONObject> mangementEvaluation1 = mangementEvaluation.getMangementEvaluation();
             responseData.setManagementEvaluation(mangementEvaluation1);
         }
         //指标推送
-        if(featureTypeList.contains("22") && diseaseSet != null && diseaseSet.size()>0){
-            logger.info("featureTypeList 包含22,走指标推送!!!,图谱推出的诊断为:"+diseaseSet);
+        if (featureTypeList.contains("22") && diseaseSet != null && diseaseSet.size() > 0) {
+            logger.info("featureTypeList 包含22,走指标推送!!!,图谱推出的诊断为:" + diseaseSet);
             List<MedicalIndication> medicalIndicationList = new ArrayList<>();
             MedicalIndication medicalIndication = this.getMedicalIndication(diseaseSet);
             medicalIndicationList.add(medicalIndication);
@@ -89,75 +91,76 @@ public class GraphCalculate {
 
     /**
      * 返回LIS,PACS
+     *
      * @param searchData
      */
-    public ResponseData getLisPacs(HttpServletRequest request,SearchData searchData) throws Exception {
+    public ResponseData getLisPacs(HttpServletRequest request, SearchData searchData) throws Exception {
         ResponseData responseData = new ResponseData();
         Neo4jAPI neo4jAPI = new Neo4jAPI(DriverManager.newDrive());
         String webDiag = searchData.getDiag();
         List<String> webDiagList = Arrays.asList(webDiag.split(",|,|、"));
         List<FeatureRate> bigdataDiagFeature = searchData.getPushDiags();
-        List<String> bigdataDiagList =new LinkedList<>();
-        if(bigdataDiagFeature.size()>0){
-            for (FeatureRate fe:bigdataDiagFeature) {
-                if("neo4j".equals(fe.getRate())){
+        List<String> bigdataDiagList = new LinkedList<>();
+        if (bigdataDiagFeature.size() > 0) {
+            for (FeatureRate fe : bigdataDiagFeature) {
+                if ("neo4j".equals(fe.getRate())) {
                     bigdataDiagList.add(fe.getFeatureName());
-                    logger.info("图谱推出的诊断为: "+fe.getFeatureName());
-                }else {
+                    logger.info("图谱推出的诊断为: " + fe.getFeatureName());
+                } else {
                     bigdataDiagList.add(fe.getFeatureName());
-                    logger.info("大数据推出的诊断为: "+fe.getFeatureName());
+                    logger.info("大数据推出的诊断为: " + fe.getFeatureName());
                 }
             }
         }
-        for (String web: webDiagList ) {
-                for (int i=0;i<bigdataDiagList.size();i++ ) {
-                    if(bigdataDiagList.get(i).equals(web)){
-                        bigdataDiagList.remove(bigdataDiagList.get(i));
-                    }
+        for (String web : webDiagList) {
+            for (int i = 0; i < bigdataDiagList.size(); i++) {
+                if (bigdataDiagList.get(i).equals(web)) {
+                    bigdataDiagList.remove(bigdataDiagList.get(i));
                 }
+            }
         }
         logger.info("界面诊断为: " + webDiagList);
         logger.info("推出的诊断合并为: " + bigdataDiagList);
-        Map<String, Set<String>> weblisPacs1 =null;
-        Map<String, Set<String>> biglisPacs1 =null;
-        if(webDiagList !=null && webDiagList.size()>0){
-            weblisPacs1=neo4jAPI.getLisPacs(webDiagList);//界面诊断推出的LIS,PACS
+        Map<String, Set<String>> weblisPacs1 = null;
+        Map<String, Set<String>> biglisPacs1 = null;
+        if (webDiagList != null && webDiagList.size() > 0) {
+            weblisPacs1 = neo4jAPI.getLisPacs(webDiagList);//界面诊断推出的LIS,PACS
         }
-        if(bigdataDiagList !=null && bigdataDiagList.size()>0){
-            biglisPacs1=neo4jAPI.getLisPacs(bigdataDiagList);//大数据推得诊断
+        if (bigdataDiagList != null && bigdataDiagList.size() > 0) {
+            biglisPacs1 = neo4jAPI.getLisPacs(bigdataDiagList);//大数据推得诊断
         }
-        Set<String> lis =null;
-        Set<String> pacs =null;
+        Set<String> lis = null;
+        Set<String> pacs = null;
         //如果界面有诊断
-        if(weblisPacs1 !=null && weblisPacs1.values().size()>0){
+        if (weblisPacs1 != null && weblisPacs1.values().size() > 0) {
             lis = weblisPacs1.get("LIS");
             pacs = weblisPacs1.get("PACS");
-            logger.info("界面有诊断的情况下,界面诊断推出的lis为: "+lis);
-            logger.info("界面有诊断的情况下,界面诊断推出的pacs为: "+pacs);
-            if(biglisPacs1 !=null && biglisPacs1.values().size()>0){
+            logger.info("界面有诊断的情况下,界面诊断推出的lis为: " + lis);
+            logger.info("界面有诊断的情况下,界面诊断推出的pacs为: " + pacs);
+            if (biglisPacs1 != null && biglisPacs1.values().size() > 0) {
                 Set<String> bl = biglisPacs1.get("LIS");
-                Set<String>  bp= biglisPacs1.get("PACS");
-                logger.info("界面有诊断的情况下,推出诊断的lis为: "+bl);
-                logger.info("界面有诊断的情况下,推出诊断的pacs为: "+bp);
+                Set<String> bp = biglisPacs1.get("PACS");
+                logger.info("界面有诊断的情况下,推出诊断的lis为: " + bl);
+                logger.info("界面有诊断的情况下,推出诊断的pacs为: " + bp);
                 lis.addAll(bl);
                 pacs.addAll(bp);
             }
-        }else {
+        } else {
             lis = biglisPacs1.get("LIS");
             pacs = biglisPacs1.get("PACS");
-            logger.info("界面无诊断的情况下,推出诊断的lis为: "+lis);
-            logger.info("界面无诊断的情况下,推出诊断的lis为: "+pacs);
+            logger.info("界面无诊断的情况下,推出诊断的lis为: " + lis);
+            logger.info("界面无诊断的情况下,推出诊断的lis为: " + pacs);
         }
         logger.info("推出的合并lis为: " + lis);
         logger.info("推出的合并pacs为: " + pacs);
         ArrayList<FeatureRate> lisFeature = new ArrayList<>();
         ArrayList<FeatureRate> pacsFeature = new ArrayList<>();
-        for (String l:lis) {
+        for (String l : lis) {
             FeatureRate featureRate = new FeatureRate();
             featureRate.setFeatureName(l);
             lisFeature.add(featureRate);
         }
-        for (String p:pacs) {
+        for (String p : pacs) {
             FeatureRate featureRate = new FeatureRate();
             featureRate.setFeatureName(p);
             pacsFeature.add(featureRate);
@@ -170,6 +173,7 @@ public class GraphCalculate {
 
     /**
      * 对化验和检查的结果进行排序
+     *
      * @param set
      * @return List<FeatureRate>
      */
@@ -192,11 +196,9 @@ public class GraphCalculate {
                     frlist.add(items.get(key));
                 }
             }
-        }
-        catch (Exception ex) {
+        } catch (Exception ex) {
             ex.printStackTrace();
-        }
-        finally {
+        } finally {
             return frlist;
         }
     }
@@ -204,6 +206,7 @@ public class GraphCalculate {
 
     /**
      * 使用 Map按value进行排序
+     *
      * @param oriMap
      * @return
      */
@@ -226,12 +229,13 @@ public class GraphCalculate {
 
     /**
      * 量表和指标
+     *
      * @param diseaseSet
      * @return
      */
-    public MedicalIndication getMedicalIndication(Set diseaseSet){
+    public MedicalIndication getMedicalIndication(Set diseaseSet) throws Exception {
         MedicalIndication medicalIndication = new MedicalIndication();
-        if(diseaseSet.contains("肾功能不全")){
+        if (diseaseSet.contains("肾功能不全")) {
             logger.info("diseaseSet中包含肾功能不全");
             //推送指标
             medicalIndication.setName("肾功能不全");
@@ -240,77 +244,77 @@ public class GraphCalculate {
             MedicalIndicationDetail medicalIndicationDetail1 = new MedicalIndicationDetail();
             medicalIndicationDetail1.setType(1);
             JSONObject liangJson = new JSONObject();
-            liangJson.put("name","密西根糖尿病周围神经病评分(MDNS)");
+            liangJson.put("name", "密西根糖尿病周围神经病评分(MDNS)");
             medicalIndicationDetail1.setContent(liangJson);
             //公式
             MedicalIndicationDetail medicalIndicationDetail2 = new MedicalIndicationDetail();
             medicalIndicationDetail2.setType(2);
             JSONObject gongshiJson = new JSONObject();
-            gongshiJson.put("name","肾小球滤过率");
+            gongshiJson.put("name", "肾小球滤过率");
             List<JSONObject> detailList = new ArrayList<>();
             JSONObject ageJsonObject = new JSONObject();
-            ageJsonObject.put("controlType",2);
-            ageJsonObject.put("name","年龄");
-            ageJsonObject.put("value","");
-            ageJsonObject.put("uint","");
-            ageJsonObject.put("details",new ArrayList<>());
+            ageJsonObject.put("controlType", 2);
+            ageJsonObject.put("name", "年龄");
+            ageJsonObject.put("value", "");
+            ageJsonObject.put("uint", "");
+            ageJsonObject.put("details", new ArrayList<>());
             JSONObject indicationJsonObject = new JSONObject();
-            indicationJsonObject.put("controlType",2);
-            indicationJsonObject.put("name","血肌酐");
-            indicationJsonObject.put("value","");
-            indicationJsonObject.put("uint","mg/dL");
-            indicationJsonObject.put("details",new ArrayList<>());
+            indicationJsonObject.put("controlType", 2);
+            indicationJsonObject.put("name", "血肌酐");
+            indicationJsonObject.put("value", "");
+            indicationJsonObject.put("uint", "mg/dL");
+            indicationJsonObject.put("details", new ArrayList<>());
             JSONObject sexJson = new JSONObject();
-            sexJson.put("controlType",3);
-            sexJson.put("name","性别");
-            sexJson.put("value","");
-            sexJson.put("uint","");
+            sexJson.put("controlType", 3);
+            sexJson.put("name", "性别");
+            sexJson.put("value", "");
+            sexJson.put("uint", "");
             List<JSONObject> sexList = new ArrayList<>();
             JSONObject manJson = new JSONObject();
-            manJson.put("detailName","男");
-            manJson.put("value",1);
-            manJson.put("state",0);
+            manJson.put("detailName", "男");
+            manJson.put("value", 1);
+            manJson.put("state", 0);
             JSONObject womanJson = new JSONObject();
-            womanJson.put("detailName","女");
-            womanJson.put("value",1.018);
-            womanJson.put("state",1);
+            womanJson.put("detailName", "女");
+            womanJson.put("value", 1.018);
+            womanJson.put("state", 1);
             sexList.add(manJson);
             sexList.add(womanJson);
-            sexJson.put("details",sexList);
+            sexJson.put("details", sexList);
             detailList.add(ageJsonObject);
             detailList.add(indicationJsonObject);
             detailList.add(sexJson);
-            gongshiJson.put("details",detailList);
-//            JSONObject resultJson = new JSONObject();
-//            resultJson.put("value","");
-//            resultJson.put("unit","");
-//            resultJson.put("text","");
-//            gongshiJson.put("result",resultJson);
+            gongshiJson.put("details", detailList);
+            //            JSONObject resultJson = new JSONObject();
+            //            resultJson.put("value", "");
+            //            resultJson.put("unit", "");
+            //            resultJson.put("text", "");
+            //            gongshiJson.put("result", resultJson);
             medicalIndicationDetail2.setContent(gongshiJson);
             //其他
             MedicalIndicationDetail medicalIndicationDetail3 = new MedicalIndicationDetail();
             medicalIndicationDetail3.setType(3);
             JSONObject shiFouJson = new JSONObject();
-            shiFouJson.put("name","是否");
-            shiFouJson.put("controlType",0);
+            shiFouJson.put("name", "是否");
+            shiFouJson.put("controlType", 0);
             List<JSONObject> shiFouList = new ArrayList<>();
             JSONObject shiJsonObject = new JSONObject();
-            shiJsonObject.put("detailName","是");
-            shiJsonObject.put("state",0);
+            shiJsonObject.put("detailName", "是");
+            shiJsonObject.put("state", 0);
             JSONObject fouJsonObject = new JSONObject();
-            fouJsonObject.put("detailName","否");
-            fouJsonObject.put("state",1);
+            fouJsonObject.put("detailName", "否");
+            fouJsonObject.put("state", 1);
             shiFouList.add(shiJsonObject);
             shiFouList.add(fouJsonObject);
-            shiFouJson.put("details",shiFouList);
+            shiFouJson.put("details", shiFouList);
             medicalIndicationDetail3.setContent(shiFouJson);
             medicalIndicationDetailList.add(medicalIndicationDetail1);
+            Map<String, Object> maps = scaleCalcMethod(medicalIndicationDetail2);
             JSONObject resultJson = new JSONObject();
-            Map<String, Object> scaleCalcMethod = scaleCalcMethod(medicalIndicationDetail2);
-            resultJson.put("value",scaleCalcMethod.get("value"));
-            resultJson.put("unit",scaleCalcMethod.get("unit"));
-            resultJson.put("text",scaleCalcMethod.get("text"));
-            gongshiJson.put("result",resultJson);
+            resultJson.put("value", maps.get("value"));
+            resultJson.put("unit", maps.get("unit"));
+            resultJson.put("text", maps.get("text"));
+            gongshiJson.put("result", resultJson);
             medicalIndicationDetail2.setContent(gongshiJson);
             medicalIndicationDetailList.add(medicalIndicationDetail2);
             medicalIndicationDetailList.add(medicalIndicationDetail3);
@@ -321,159 +325,168 @@ public class GraphCalculate {
 
     /**
      * 管理评估
+     *
      * @return
      */
-    public MangementEvaluation getMangementEvaluation(){
+    public MangementEvaluation getMangementEvaluation() {
         MangementEvaluation mangementEvaluation = new MangementEvaluation();
-        Map<String,JSONObject> mangementMap = new HashMap<>();
+        Map<String, JSONObject> mangementMap = new HashMap<>();
         JSONObject curativeJson = new JSONObject();
         List<JSONObject> itemJson = new ArrayList<>();
         JSONObject bloodPressure = new JSONObject();
-        bloodPressure.put("controltype",0);
-        bloodPressure.put("name","血压控制情况");
+        bloodPressure.put("controltype", 0);
+        bloodPressure.put("name", "血压控制情况");
         List<JSONObject> bloodPressureLevelList = new ArrayList<>();
-        String[] items= {"正常","1级","2级","3级"};
-        for (String item:items) {
+        String[] items = { "正常", "1级", "2级", "3级" };
+        for (String item : items) {
             JSONObject iJson = new JSONObject();
-            iJson.put("detailName",item);
-            iJson.put("state",0);
+            iJson.put("detailName", item);
+            iJson.put("state", 0);
             bloodPressureLevelList.add(iJson);
         }
-        bloodPressure.put("details",bloodPressureLevelList);
+        bloodPressure.put("details", bloodPressureLevelList);
         itemJson.add(bloodPressure);
 
         JSONObject bmiControl = new JSONObject();
-        bmiControl.put("controltype",0);
-        bmiControl.put("name","BMI控制情况");
+        bmiControl.put("controltype", 0);
+        bmiControl.put("name", "BMI控制情况");
         List<JSONObject> bmiControlLevelList = new ArrayList<>();
-        String[] bmiControlitems= {"体重过低","体重达标","肥胖前期","肥胖"};
-        for (String item:bmiControlitems) {
+        String[] bmiControlitems = { "体重过低", "体重达标", "肥胖前期", "肥胖" };
+        for (String item : bmiControlitems) {
             JSONObject iJson = new JSONObject();
-            iJson.put("detailName",item);
-            iJson.put("state",0);
+            iJson.put("detailName", item);
+            iJson.put("state", 0);
             bmiControlLevelList.add(iJson);
         }
-        bmiControl.put("details",bmiControlLevelList);
+        bmiControl.put("details", bmiControlLevelList);
         itemJson.add(bmiControl);
 
         JSONObject bloodFatControl = new JSONObject();
-        bloodFatControl.put("controltype",0);
-        bloodFatControl.put("name","血脂控制情况");
+        bloodFatControl.put("controltype", 0);
+        bloodFatControl.put("name", "血脂控制情况");
         List<JSONObject> bloodFatControlLevelList = new ArrayList<>();
-        String[] bloodFatControlitems= {"高血脂"};
-        for (String item:bloodFatControlitems) {
+        String[] bloodFatControlitems = { "高血脂" };
+        for (String item : bloodFatControlitems) {
             JSONObject iJson = new JSONObject();
-            iJson.put("detailName",item);
-            iJson.put("state",0);
+            iJson.put("detailName", item);
+            iJson.put("state", 0);
             bloodFatControlLevelList.add(iJson);
         }
-        bloodFatControl.put("details",bmiControlLevelList);
+        bloodFatControl.put("details", bmiControlLevelList);
         itemJson.add(bloodFatControl);
-        curativeJson.put("rows",itemJson);
+        curativeJson.put("rows", itemJson);
         //分级管理
         JSONObject gradeJson = new JSONObject();
         List<JSONObject> gradItemJson = new ArrayList<>();
         JSONObject bigGrad = new JSONObject();
-        bigGrad.put("name","血压控制情况");
-        bigGrad.put("controltype",0);
+        bigGrad.put("name", "血压控制情况");
+        bigGrad.put("controltype", 0);
         List<JSONObject> gradItemJ = new ArrayList<>();
-        String[] gradItem ={"常规管理","强化管理"};
-        for (String item:gradItem) {
-            JSONObject j =new JSONObject();
-            j.put("detailName",item);
-            j.put("state",0);
+        String[] gradItem = { "常规管理", "强化管理" };
+        for (String item : gradItem) {
+            JSONObject j = new JSONObject();
+            j.put("detailName", item);
+            j.put("state", 0);
             gradItemJ.add(j);
         }
-        bigGrad.put("details",gradItemJ);
+        bigGrad.put("details", gradItemJ);
         gradItemJson.add(bigGrad);
-        gradeJson.put("rows",gradItemJson);
-        mangementMap.put("疗效评估",curativeJson);
-        mangementMap.put("糖尿病分级管理",gradeJson);
+        gradeJson.put("rows", gradItemJson);
+        mangementMap.put("疗效评估", curativeJson);
+        mangementMap.put("糖尿病分级管理", gradeJson);
         mangementEvaluation.setMangementEvaluation(mangementMap);
         return mangementEvaluation;
     }
 
-    public Map<String, Object> scaleCalcMethod(MedicalIndicationDetail medicalIndicationDetail) {
+    public Map<String, Object> scaleCalcMethod(MedicalIndicationDetail medicalIndicationDetail) throws Exception {
         Map<String, Object> scaleCalcResult = new HashMap<>();
         Integer type = medicalIndicationDetail.getType();
-        switch (type) {
-            case 3:
-                //                        result = scaleScoreCalc(scaleItems, scaleName).get("text").toString();
-                break;
-            case 2:
-                JSONObject content = medicalIndicationDetail.getContent();
-                JSONArray contentDetails = content.getJSONArray("details");
-                int age = 0;
-                double scr = 0.00;
-                float k = 0.0f;
-                double a = 0.00;
-                double denger = 0.00;
-                for (int i = 0; i < contentDetails.size(); i++) {
-                    JSONObject detailSub = contentDetails.getJSONObject(i);
-                    if ("年龄".equals(detailSub.getString("name"))) {
-                        if ("".equals(detailSub.getString("value"))) {
-                            //如果拿到的年龄为空,给的20是假数据
-                            age = 20;
+        if (type == 1) {
+            //                    case 1:
+            //                        Set<String> inputs = searchData.getInputs().keySet();
+            //                        String[] input = inputs.toArray(new String[inputs.size()]);
+            //                        Map<String, Object> stringObjectMap = neo4jAPI.scaleScoreCalc(input, searchData.getScaleName());
+            //                        scaleCalcResultList.add(stringObjectMap);
+            //                        break;
+        } else if (type == 2) {
+            JSONObject content = medicalIndicationDetail.getContent();
+            JSONArray contentDetails = content.getJSONArray("details");
+            int age = 0;
+            double scr = 0.00;
+            float k = 0.0f;
+            double a = 0.00;
+            double denger = 0.00;
+            for (int i = 0; i < contentDetails.size(); i++) {
+                JSONObject detailSub = contentDetails.getJSONObject(i);
+                if ("年龄".equals(detailSub.getString("name"))) {
+                    if ("".equals(detailSub.getString("value"))) {
+                        //如果拿到的年龄为空,
+                        break;
+                    } else {
+                        age = Integer.parseInt(detailSub.getString("value"));
+                    }
+                } else if ("血肌酐".equals(detailSub.getString("name"))) {
+                    if ("".equals(detailSub.getString("value"))) {
+                        //如果给的value是空,给的2.2621是假数据
+                        break;
+                    } else {
+                        if ("umol/L".equals(detailSub.getString("value"))) {
+                            scr = Double.valueOf(detailSub.getString("value")) / 88.41;
                         } else {
-                            age = Integer.parseInt(detailSub.getString("value"));
+                            scr = Double.valueOf(detailSub.getString("value"));
                         }
-                    } else if ("血肌酐".equals(detailSub.getString("name"))) {
-                        if ("".equals(detailSub.getString("value"))) {
-                            //如果给的value是空,给的2.2621是假数据
-                            scr = 2.2621;
-                        } else {
-                            if ("umol/L".equals(detailSub.getString("value"))) {
-                                scr = Double.valueOf(detailSub.getString("value")) / 88.41;
-                            } else {
-                                scr = Double.valueOf(detailSub.getString("value"));
-                            }
-                        }
-                    } else if ("性别".equals(detailSub.getString("name"))) {
-                        JSONArray genderDetails = detailSub.getJSONArray("details");
-                        for (int j = 0; j < genderDetails.size(); j++) {
-                            JSONObject genderDetail = genderDetails.getJSONObject(j);
-                            //返回的数据结构性别暂时是写死(默认女性)
-                            if (genderDetail.getInteger("state") == 1) {
-                                if ("男".equals(genderDetail.getString("detailName"))) {
-                                    k = 0.9f;
-                                    denger = Double.parseDouble(genderDetail.getString("value"));
-                                    if (scr <= 0.90) {
-                                        a = -0.411;
-                                    } else {
-                                        a = -1.209;
-                                    }
-                                } else if ("女".equals(genderDetail.getString("detailName"))) {
-                                    k = 0.7f;
-                                    denger = Double.parseDouble(genderDetail.getString("value"));
-                                    if (scr <= 0.70) {
-                                        a = -0.329;
-                                    } else {
-                                        a = -1.209;
-                                    }
+                    }
+                } else if ("性别".equals(detailSub.getString("name"))) {
+                    JSONArray genderDetails = detailSub.getJSONArray("details");
+                    for (int j = 0; j < genderDetails.size(); j++) {
+                        JSONObject genderDetail = genderDetails.getJSONObject(j);
+                        //返回的数据结构性别暂时是写死(默认女性)
+                        if (genderDetail.getInteger("state") == 1) {
+                            if ("男".equals(genderDetail.getString("detailName"))) {
+                                k = 0.9f;
+                                denger = Double.parseDouble(genderDetail.getString("value"));
+                                if (scr <= 0.90) {
+                                    a = -0.411;
+                                } else {
+                                    a = -1.209;
+                                }
+                            } else if ("女".equals(genderDetail.getString("detailName"))) {
+                                k = 0.7f;
+                                denger = Double.parseDouble(genderDetail.getString("value"));
+                                if (scr <= 0.70) {
+                                    a = -0.329;
+                                } else {
+                                    a = -1.209;
                                 }
                             }
                         }
                     }
                 }
-                double eGFR3 = 141 * Math.pow((scr / k), a) * Math.pow(0.993, age) * denger;
-                String unit = "ml/min•1.73m2";
-                String text = null;
-                if (eGFR3 <= 15) {
-                    text = "肾功能衰竭";
-                } else if (eGFR3 > 15 && eGFR3 <= 29) {
-                    text = "重度下降";
-                } else if (eGFR3 > 30 && eGFR3 <= 59) {
-                    text = "中度下降";
-                } else if (eGFR3 > 60 && eGFR3 <= 89) {
-                    text = "轻度下降";
-                } else if (eGFR3 >= 90) {
-                    text = "正常或肾损伤代偿期";
-                }
-                scaleCalcResult.put("text", text);
-                scaleCalcResult.put("unit", unit);
-                scaleCalcResult.put("value", eGFR3);
-                System.out.println("text:" + text + "\tunit:" + unit + "\tvalue:" + eGFR3);
+            }
+            double eGFR3 = 141 * Math.pow((scr / k), a) * Math.pow(0.993, age) * denger;
+            String unit = "ml/min•1.73m2";
+            String text = null;
+            if (eGFR3 <= 0) {
+                text = "指标值缺少";
+            } else if (eGFR3 > 0 && eGFR3 <= 15) {
+                text = "肾功能衰竭";
+            } else if (eGFR3 > 15 && eGFR3 <= 29) {
+                text = "重度下降";
+            } else if (eGFR3 > 30 && eGFR3 <= 59) {
+                text = "中度下降";
+            } else if (eGFR3 > 60 && eGFR3 <= 89) {
+                text = "轻度下降";
+            } else if (eGFR3 >= 90) {
+                text = "正常或肾损伤代偿期";
+            }
+
+            scaleCalcResult.put("text", text);
+            scaleCalcResult.put("unit", unit);
+            scaleCalcResult.put("value", eGFR3);
+            System.out.println("text:" + text + "\tunit:" + unit + "\tvalue:" + eGFR3);
         }
+
+
         return scaleCalcResult;
     }
 }

+ 23 - 1
push-web/src/main/java/org/diagbot/push/controller/GraphController.java

@@ -1,5 +1,7 @@
 package org.diagbot.push.controller;
 
+import org.diagbot.common.javabean.MedicalIndication;
+import org.diagbot.common.javabean.MedicalIndicationDetail;
 import org.diagbot.common.work.ResponseData;
 import org.diagbot.common.work.SearchData;
 import org.diagbot.graph.javabean.GdbResponse;
@@ -8,7 +10,6 @@ import org.diagbot.graph.jdbc.Neo4jAPI;
 import org.diagbot.graphWeb.work.GraphCalculate;
 import org.diagbot.graphWeb.work.HighRiskCalculate;
 import org.diagbot.graphWeb.work.LisPacsCalculate;
-import org.diagbot.graphWeb.work.ScaleCalculate;
 import org.diagbot.pub.api.Response;
 import org.diagbot.pub.web.BaseController;
 import org.neo4j.driver.v1.Driver;
@@ -19,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -92,4 +96,22 @@ public class GraphController extends BaseController {
         return scale;
     }
 
+    @RequestMapping(value = "/scaleCalc", method = RequestMethod.POST)
+    @ResponseBody
+    public List<Map<String, Object>> scaleCalc(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
+        List<Map<String, Object>> mapList = new ArrayList<>();
+        Map<String, Object> maps = null;
+        GraphCalculate graphCalculate = new GraphCalculate();
+        ResponseData responseData = graphCalculate.calculate(request, searchData);
+        List<MedicalIndication> medicalIndications = responseData.getMedicalIndications();
+        for (MedicalIndication medicalIndication : medicalIndications) {
+            List<MedicalIndicationDetail> details = medicalIndication.getDetails();
+            for (MedicalIndicationDetail medicalIndicationDetail : details) {
+                maps = graphCalculate.scaleCalcMethod(medicalIndicationDetail);
+                mapList.add(maps);
+            }
+        }
+        return mapList;
+    }
+
 }