Commit ae2adb2e49664569e149e67da40771fba1021a4f
1 parent
04376c3d0a
Exists in
master
and in
6 other branches
专科门诊血压血糖瘢痕管理
Showing 5 changed files with 1467 additions and 2 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BloodPressurePatientWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BloodSugarPatientWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ScarUterusPatientWorker.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
View file @
ae2adb2
| ... | ... | @@ -157,10 +157,51 @@ |
| 157 | 157 | @TokenRequired |
| 158 | 158 | public BaseResponse queryTwinsAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { |
| 159 | 159 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 160 | - | |
| 161 | - //该方法还没有修改,为 ,双胎全部孕妇管理,使用。删除高危,删除产妇,保留孕妇,加上需求特定字段即可 | |
| 162 | 160 | return patientFacade.queryTwinsAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); |
| 163 | 161 | } |
| 162 | + | |
| 163 | + /** | |
| 164 | + * 血压全部孕妇管理 | |
| 165 | + * | |
| 166 | + * @param patientsQueryRequest | |
| 167 | + * @return 返回结果 | |
| 168 | + */ | |
| 169 | + @RequestMapping(value = "/bloodPressure", method = RequestMethod.GET) | |
| 170 | + @ResponseBody | |
| 171 | + @TokenRequired | |
| 172 | + public BaseResponse queryBloodPressureAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
| 173 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 174 | + return patientFacade.queryBloodPressureAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); | |
| 175 | + } | |
| 176 | + | |
| 177 | + /** | |
| 178 | + * 血糖全部孕妇管理 | |
| 179 | + * | |
| 180 | + * @param patientsQueryRequest | |
| 181 | + * @return 返回结果 | |
| 182 | + */ | |
| 183 | + @RequestMapping(value = "/bloodSugar", method = RequestMethod.GET) | |
| 184 | + @ResponseBody | |
| 185 | + @TokenRequired | |
| 186 | + public BaseResponse queryBloodSugarAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
| 187 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 188 | + return patientFacade.queryBloodSugarAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); | |
| 189 | + } | |
| 190 | + /** | |
| 191 | + * 瘢痕子宫全部孕妇管理 | |
| 192 | + * | |
| 193 | + * @param patientsQueryRequest | |
| 194 | + * @return 返回结果 | |
| 195 | + */ | |
| 196 | + @RequestMapping(value = "/scarUterus", method = RequestMethod.GET) | |
| 197 | + @ResponseBody | |
| 198 | + @TokenRequired | |
| 199 | + public BaseResponse queryScarUterusAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
| 200 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 201 | + return patientFacade.queryScarUterusAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); | |
| 202 | + } | |
| 203 | + | |
| 204 | + | |
| 164 | 205 | |
| 165 | 206 | /** |
| 166 | 207 | * 稀有血型专病门诊管理list |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
ae2adb2
| ... | ... | @@ -769,6 +769,256 @@ |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
| 772 | + * 查询血压全部孕妇管理 | |
| 773 | + * @param riskPatientsQueryRequest | |
| 774 | + * @param isHighRisk | |
| 775 | + * @param type | |
| 776 | + * @param userId | |
| 777 | + * @param needPage | |
| 778 | + * @param isRegion | |
| 779 | + * @return | |
| 780 | + */ | |
| 781 | + public BaseResponse queryBloodPressureAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { | |
| 782 | + //组合请求 | |
| 783 | + PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion); | |
| 784 | + | |
| 785 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
| 786 | + //查询符合条件的孕妇 | |
| 787 | + StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); | |
| 788 | + stopWatch.start(); | |
| 789 | + | |
| 790 | + Query yn = null; | |
| 791 | + if ("1".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 792 | + Criteria criteria1 = Criteria.where("name").is("妊娠期高血压疾病(除外红、橙色)"); | |
| 793 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1)); | |
| 794 | + } else if ("2".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 795 | + Criteria criteria2 = Criteria.where("name").is("妊娠期高血压"); | |
| 796 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria2)); | |
| 797 | + } else if ("3".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 798 | + Criteria criteria3 = Criteria.where("name").is("子痫前期(轻)"); | |
| 799 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria3)); | |
| 800 | + }else if ("4".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 801 | + Criteria criteria4 = Criteria.where("name").is("慢性高血压合并妊娠"); | |
| 802 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 803 | + }else if ("5".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 804 | + Criteria criteria5 = Criteria.where("name").is("妊娠期高血压性心脏病"); | |
| 805 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria5)); | |
| 806 | + }else if ("6".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 807 | + Criteria criteria6 = Criteria.where("name").is("急性肾脏疾病伴高血压"); | |
| 808 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria6)); | |
| 809 | + }else if ("7".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 810 | + Criteria criteria7 = Criteria.where("name").is("慢性肾脏疾病伴高血压"); | |
| 811 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria7)); | |
| 812 | + } | |
| 813 | + | |
| 814 | + else { | |
| 815 | + Criteria criteria1 = Criteria.where("name").is("妊娠期高血压疾病(除外红、橙色)"); | |
| 816 | + Criteria criteria2 = Criteria.where("name").is("妊娠期高血压"); | |
| 817 | + Criteria criteria3 = Criteria.where("name").is("子痫前期(轻)"); | |
| 818 | + Criteria criteria4 = Criteria.where("name").is("慢性高血压合并妊娠"); | |
| 819 | + Criteria criteria5 = Criteria.where("name").is("妊娠期高血压性心脏病"); | |
| 820 | + Criteria criteria6 = Criteria.where("name").is("急性肾脏疾病伴高血压"); | |
| 821 | + Criteria criteria7 = Criteria.where("name").is("慢性肾脏疾病伴高血压"); | |
| 822 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2, criteria3,criteria4,criteria5,criteria6,criteria7)); | |
| 823 | + } | |
| 824 | + List<BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class); | |
| 825 | + List<String> rFactorList = new ArrayList<>(); | |
| 826 | + if (models != null && models.size() > 0) { | |
| 827 | + for (int i = 0; i < models.size(); i++) { | |
| 828 | + rFactorList.add(models.get(i).getId()); | |
| 829 | + } | |
| 830 | + } | |
| 831 | + patientsQuery.setrFactorList(rFactorList); | |
| 832 | + List<Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
| 833 | + stopWatch.stop(); | |
| 834 | + | |
| 835 | + logger.info(stopWatch.toString()); | |
| 836 | + List data = new ArrayList<QuanChanResult>(); | |
| 837 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 838 | + if (type == 1) { | |
| 839 | + //处理全部孕妇的情况 | |
| 840 | + data = convertToBloodPressurePatient(riskPatientsQueryRequest, patientses, userId, hospital); | |
| 841 | + } | |
| 842 | + } | |
| 843 | +// patientsQuery.mysqlBuild(data.size()); | |
| 844 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
| 845 | + } | |
| 846 | + | |
| 847 | + /** | |
| 848 | + * 查询血糖全部孕妇管理 | |
| 849 | + * @param riskPatientsQueryRequest | |
| 850 | + * @param isHighRisk | |
| 851 | + * @param type | |
| 852 | + * @param userId | |
| 853 | + * @param needPage | |
| 854 | + * @param isRegion | |
| 855 | + * @return | |
| 856 | + */ | |
| 857 | + public BaseResponse queryBloodSugarAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { | |
| 858 | + //组合请求 | |
| 859 | + PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion); | |
| 860 | + | |
| 861 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
| 862 | + //查询符合条件的孕妇 | |
| 863 | + StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); | |
| 864 | + stopWatch.start(); | |
| 865 | + | |
| 866 | + Query yn = null; | |
| 867 | + if ("1".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 868 | + Criteria criteria1 = Criteria.where("name").is("妊娠期糖尿病(无需药物治疗)"); | |
| 869 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1)); | |
| 870 | + } else if ("2".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 871 | + Criteria criteria2 = Criteria.where("name").is("妊娠期糖尿病病史"); | |
| 872 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria2)); | |
| 873 | + } else if ("3".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 874 | + Criteria criteria3 = Criteria.where("name").is("糖尿病合并妊娠(无需药物治疗)"); | |
| 875 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria3)); | |
| 876 | + }else if ("4".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 877 | + Criteria criteria4 = Criteria.where("name").is("糖尿病并发肾病V级、严重心血管病、增生性视网膜病变或玻璃体出血、周围神经病变等"); | |
| 878 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 879 | + }else if ("5".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 880 | + Criteria criteria5 = Criteria.where("name").is("糖尿病并发肾病V级"); | |
| 881 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria5)); | |
| 882 | + }else if ("6".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 883 | + Criteria criteria6 = Criteria.where("name").is("糖尿病并发严重心血管病"); | |
| 884 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria6)); | |
| 885 | + }else if ("7".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 886 | + Criteria criteria7 = Criteria.where("name").is("糖尿病并发增生性视网膜病变"); | |
| 887 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria7)); | |
| 888 | + }else if ("8".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 889 | + Criteria criteria8 = Criteria.where("name").is("糖尿病并发玻璃体出血"); | |
| 890 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria8)); | |
| 891 | + }else if ("9".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 892 | + Criteria criteria9 = Criteria.where("name").is("糖尿病并发周围神经病变等"); | |
| 893 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria9)); | |
| 894 | + } | |
| 895 | + | |
| 896 | + else { | |
| 897 | + Criteria criteria1 = Criteria.where("name").is("妊娠期糖尿病(无需药物治疗)"); | |
| 898 | + Criteria criteria2 = Criteria.where("name").is("妊娠期糖尿病病史"); | |
| 899 | + Criteria criteria3 = Criteria.where("name").is("糖尿病合并妊娠(无需药物治疗)"); | |
| 900 | + Criteria criteria4 = Criteria.where("name").is("糖尿病并发肾病V级、严重心血管病、增生性视网膜病变或玻璃体出血、周围神经病变等"); | |
| 901 | + Criteria criteria5 = Criteria.where("name").is("糖尿病并发肾病V级"); | |
| 902 | + Criteria criteria6 = Criteria.where("name").is("糖尿病并发严重心血管病"); | |
| 903 | + Criteria criteria7 = Criteria.where("name").is("糖尿病并发增生性视网膜病变"); | |
| 904 | + Criteria criteria8 = Criteria.where("name").is("糖尿病并发玻璃体出血"); | |
| 905 | + Criteria criteria9 = Criteria.where("name").is("糖尿病并发周围神经病变等"); | |
| 906 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2, criteria3,criteria4,criteria5,criteria6,criteria7,criteria8,criteria9)); | |
| 907 | + } | |
| 908 | + List<BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class); | |
| 909 | + List<String> rFactorList = new ArrayList<>(); | |
| 910 | + if (models != null && models.size() > 0) { | |
| 911 | + for (int i = 0; i < models.size(); i++) { | |
| 912 | + rFactorList.add(models.get(i).getId()); | |
| 913 | + } | |
| 914 | + } | |
| 915 | + patientsQuery.setrFactorList(rFactorList); | |
| 916 | + List<Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
| 917 | + stopWatch.stop(); | |
| 918 | + | |
| 919 | + logger.info(stopWatch.toString()); | |
| 920 | + List data = new ArrayList<QuanChanResult>(); | |
| 921 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 922 | + if (type == 1) { | |
| 923 | + //处理全部孕妇的情况 | |
| 924 | + data = convertToBloodSugarPatient(riskPatientsQueryRequest, patientses, userId, hospital); | |
| 925 | + } | |
| 926 | + } | |
| 927 | +// patientsQuery.mysqlBuild(data.size()); | |
| 928 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
| 929 | + } | |
| 930 | + public BaseResponse queryScarUterusAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { | |
| 931 | + //组合请求 | |
| 932 | + PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion); | |
| 933 | + | |
| 934 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
| 935 | + //查询符合条件的孕妇 | |
| 936 | + StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); | |
| 937 | + stopWatch.start(); | |
| 938 | + | |
| 939 | + Query yn = null; | |
| 940 | + if ("1".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 941 | + Criteria criteria1 = Criteria.where("name").is("瘢痕子宫"); | |
| 942 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1)); | |
| 943 | + } else if ("2".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 944 | + Criteria criteria2 = Criteria.where("name").is("剖宫产1次"); | |
| 945 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria2)); | |
| 946 | + } else if ("3".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 947 | + Criteria criteria3 = Criteria.where("name").is("子宫肌瘤挖出术1次"); | |
| 948 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria3)); | |
| 949 | + }else if ("4".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 950 | + Criteria criteria4 = Criteria.where("name").is("宫角妊娠1次"); | |
| 951 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 952 | + }else if ("5".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 953 | + Criteria criteria5 = Criteria.where("name").is("瘢痕子宫(距 末次子宫手术间隔<18月)"); | |
| 954 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria5)); | |
| 955 | + }else if ("6".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 956 | + Criteria criteria6 = Criteria.where("name").is("疤痕子宫伴中央性前置胎盘或伴有可疑胎盘植入"); | |
| 957 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria6)); | |
| 958 | + }else if ("7".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 959 | + Criteria criteria7 = Criteria.where("name").is("瘢痕子宫伴中央性前置胎盘"); | |
| 960 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria7)); | |
| 961 | + }else if ("8".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 962 | + Criteria criteria8 = Criteria.where("name").is("瘢痕子宫伴有可疑胎盘植入"); | |
| 963 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria8)); | |
| 964 | + }else if ("9".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 965 | + Criteria criteria9 = Criteria.where("name").is("各类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥2次"); | |
| 966 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria9)); | |
| 967 | + }else if ("10".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 968 | + Criteria criteria10 = Criteria.where("name").is("剖宫产≥2次"); | |
| 969 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria10)); | |
| 970 | + }else if ("11".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 971 | + Criteria criteria11 = Criteria.where("name").is("宫角妊娠≥2次"); | |
| 972 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria11)); | |
| 973 | + }else if ("12".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 974 | + Criteria criteria12 = Criteria.where("name").is("子宫肌瘤挖出术≥2次"); | |
| 975 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria12)); | |
| 976 | + }else if ("13".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 977 | + Criteria criteria13 = Criteria.where("name").is("各类子宫手术史≥2次"); | |
| 978 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria13)); | |
| 979 | + } | |
| 980 | + | |
| 981 | + else { | |
| 982 | + Criteria criteria1 = Criteria.where("name").is("瘢痕子宫"); | |
| 983 | + Criteria criteria2 = Criteria.where("name").is("剖宫产1次"); | |
| 984 | + Criteria criteria3 = Criteria.where("name").is("子宫肌瘤挖出术1次"); | |
| 985 | + Criteria criteria4 = Criteria.where("name").is("宫角妊娠1次"); | |
| 986 | + Criteria criteria5 = Criteria.where("name").is("瘢痕子宫(距末次子宫手术间隔<18月)"); | |
| 987 | + Criteria criteria6 = Criteria.where("name").is("疤痕子宫伴中央性前置胎盘或伴有可疑胎盘植入"); | |
| 988 | + Criteria criteria7 = Criteria.where("name").is("瘢痕子宫伴中央性前置胎盘"); | |
| 989 | + Criteria criteria8 = Criteria.where("name").is("瘢痕子宫伴有可疑胎盘植入"); | |
| 990 | + Criteria criteria9 = Criteria.where("name").is("各类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥2次"); | |
| 991 | + Criteria criteria10 = Criteria.where("name").is("宫角妊娠≥2次"); | |
| 992 | + Criteria criteria11 = Criteria.where("name").is("子宫肌瘤挖出术≥2次"); | |
| 993 | + Criteria criteria12 = Criteria.where("name").is("各类子宫手术史≥2次"); | |
| 994 | + Criteria criteria13 = Criteria.where("name").is("剖宫产≥2次"); | |
| 995 | + | |
| 996 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2, criteria3,criteria4,criteria5,criteria6,criteria7,criteria8,criteria9,criteria10,criteria11,criteria12,criteria13)); | |
| 997 | + } | |
| 998 | + List<BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class); | |
| 999 | + List<String> rFactorList = new ArrayList<>(); | |
| 1000 | + if (models != null && models.size() > 0) { | |
| 1001 | + for (int i = 0; i < models.size(); i++) { | |
| 1002 | + rFactorList.add(models.get(i).getId()); | |
| 1003 | + } | |
| 1004 | + } | |
| 1005 | + patientsQuery.setrFactorList(rFactorList); | |
| 1006 | + List<Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
| 1007 | + stopWatch.stop(); | |
| 1008 | + | |
| 1009 | + logger.info(stopWatch.toString()); | |
| 1010 | + List data = new ArrayList<QuanChanResult>(); | |
| 1011 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 1012 | + if (type == 1) { | |
| 1013 | + //处理全部孕妇的情况 | |
| 1014 | + data = convertToScarUterusPatient(riskPatientsQueryRequest, patientses, userId, hospital); | |
| 1015 | + } | |
| 1016 | + } | |
| 1017 | +// patientsQuery.mysqlBuild(data.size()); | |
| 1018 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
| 1019 | + } | |
| 1020 | + | |
| 1021 | + /** | |
| 772 | 1022 | * 稀有血型专病门诊管理list |
| 773 | 1023 | * |
| 774 | 1024 | * @param riskPatientsQueryRequest |
| ... | ... | @@ -915,6 +1165,69 @@ |
| 915 | 1165 | end = patientses.size(); |
| 916 | 1166 | } |
| 917 | 1167 | listFuture.add(commonThreadPool.submit(new TwinsPatientWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); |
| 1168 | + } | |
| 1169 | + for (Future f : listFuture) { | |
| 1170 | + try { | |
| 1171 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 1172 | + } catch (Exception e) { | |
| 1173 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 1174 | + } | |
| 1175 | + } | |
| 1176 | + return data; | |
| 1177 | + } | |
| 1178 | + private List convertToBloodPressurePatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) { | |
| 1179 | + List data = new ArrayList<>(); | |
| 1180 | + int batchSize = 4; | |
| 1181 | + int end = 0; | |
| 1182 | + List<Future> listFuture = new ArrayList<>(); | |
| 1183 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 1184 | + end = (end + batchSize); | |
| 1185 | + if (end > patientses.size()) { | |
| 1186 | + end = patientses.size(); | |
| 1187 | + } | |
| 1188 | + listFuture.add(commonThreadPool.submit(new BloodPressurePatientWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); | |
| 1189 | + } | |
| 1190 | + for (Future f : listFuture) { | |
| 1191 | + try { | |
| 1192 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 1193 | + } catch (Exception e) { | |
| 1194 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 1195 | + } | |
| 1196 | + } | |
| 1197 | + return data; | |
| 1198 | + } | |
| 1199 | + private List convertToBloodSugarPatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) { | |
| 1200 | + List data = new ArrayList<>(); | |
| 1201 | + int batchSize = 4; | |
| 1202 | + int end = 0; | |
| 1203 | + List<Future> listFuture = new ArrayList<>(); | |
| 1204 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 1205 | + end = (end + batchSize); | |
| 1206 | + if (end > patientses.size()) { | |
| 1207 | + end = patientses.size(); | |
| 1208 | + } | |
| 1209 | + listFuture.add(commonThreadPool.submit(new BloodSugarPatientWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); | |
| 1210 | + } | |
| 1211 | + for (Future f : listFuture) { | |
| 1212 | + try { | |
| 1213 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 1214 | + } catch (Exception e) { | |
| 1215 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 1216 | + } | |
| 1217 | + } | |
| 1218 | + return data; | |
| 1219 | + } | |
| 1220 | + private List convertToScarUterusPatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) { | |
| 1221 | + List data = new ArrayList<>(); | |
| 1222 | + int batchSize = 4; | |
| 1223 | + int end = 0; | |
| 1224 | + List<Future> listFuture = new ArrayList<>(); | |
| 1225 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 1226 | + end = (end + batchSize); | |
| 1227 | + if (end > patientses.size()) { | |
| 1228 | + end = patientses.size(); | |
| 1229 | + } | |
| 1230 | + listFuture.add(commonThreadPool.submit(new ScarUterusPatientWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); | |
| 918 | 1231 | } |
| 919 | 1232 | for (Future f : listFuture) { |
| 920 | 1233 | try { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BloodPressurePatientWorker.java
View file @
ae2adb2
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.PatientsService; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; | |
| 14 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 15 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 16 | +import com.lyms.platform.operate.web.result.TwinsPatientsResult; | |
| 17 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
| 18 | +import com.lyms.platform.permission.model.Organization; | |
| 19 | +import com.lyms.platform.permission.model.Users; | |
| 20 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 21 | +import com.lyms.platform.permission.service.UsersService; | |
| 22 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 23 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 24 | +import com.lyms.platform.pojo.BasicConfig; | |
| 25 | +import com.lyms.platform.pojo.Patients; | |
| 26 | +import com.lyms.platform.query.AntExChuQuery; | |
| 27 | +import com.lyms.platform.query.AntExQuery; | |
| 28 | +import org.apache.commons.collections.CollectionUtils; | |
| 29 | +import org.apache.commons.lang.StringUtils; | |
| 30 | +import org.apache.commons.lang.math.NumberUtils; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.util.StopWatch; | |
| 34 | + | |
| 35 | +import java.util.*; | |
| 36 | +import java.util.concurrent.Callable; | |
| 37 | + | |
| 38 | +/** | |
| 39 | + * 全部孕妇列表 | |
| 40 | + */ | |
| 41 | +public class BloodPressurePatientWorker implements Callable<List<QuanPatientsResult>> { | |
| 42 | + | |
| 43 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 44 | + | |
| 45 | + private List<Patients> patientses; | |
| 46 | + | |
| 47 | + private String hospital; | |
| 48 | + private UsersService usersService; | |
| 49 | + private AntenatalExaminationService antExService; | |
| 50 | + private BasicConfigService basicConfigService; | |
| 51 | + private PatientsService patientsService; | |
| 52 | + private OrganizationService organizationService; | |
| 53 | + private RiskPatientsQueryRequest riskPatientsQueryRequest; | |
| 54 | + | |
| 55 | + public BloodPressurePatientWorker(RiskPatientsQueryRequest riskPatientsQueryRequest, | |
| 56 | + List<Patients> patientses, | |
| 57 | + UsersService usersService, | |
| 58 | + String hospital, | |
| 59 | + AntenatalExaminationService antExService, | |
| 60 | + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) { | |
| 61 | + this.riskPatientsQueryRequest = riskPatientsQueryRequest; | |
| 62 | + this.patientses = patientses; | |
| 63 | + this.usersService = usersService; | |
| 64 | + this.antExService = antExService; | |
| 65 | + this.hospital = hospital; | |
| 66 | + this.basicConfigService = basicConfigService; | |
| 67 | + this.patientsService = patientsService; | |
| 68 | + this.organizationService = organizationService; | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public List<QuanPatientsResult> call() throws Exception { | |
| 73 | + List data = new ArrayList<>(); | |
| 74 | + AntExQuery antExQuery = new AntExQuery(); | |
| 75 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 76 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
| 77 | + | |
| 78 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
| 79 | + String twinsType = ""; | |
| 80 | + if(StringUtils.isNotEmpty(riskPatientsQueryRequest.getTwinsType())){ | |
| 81 | + twinsType = riskPatientsQueryRequest.getTwinsType(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + for (Patients patients : patientses) { | |
| 85 | + | |
| 86 | + StopWatch stopWatch = new StopWatch("TwinsPatientWorker -" + patients.getId()); | |
| 87 | + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult(); | |
| 88 | + twinsPatientsResult.setYi("-"); | |
| 89 | + twinsPatientsResult.setEr("-"); | |
| 90 | + twinsPatientsResult.setSan("-"); | |
| 91 | + twinsPatientsResult.setSi("-"); | |
| 92 | + twinsPatientsResult.setWu("-"); | |
| 93 | + twinsPatientsResult.convertToResult(patients); | |
| 94 | + antExQuery.setPid(patients.getPid()); | |
| 95 | + //增加查询本次产程条数 | |
| 96 | + antExQuery.setStart(patients.getLastMenses()); | |
| 97 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 98 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 99 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 100 | + if (null != users) { | |
| 101 | + twinsPatientsResult.setlName(users.getName()); | |
| 102 | + } else { | |
| 103 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 104 | + } | |
| 105 | + } else { | |
| 106 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + //筛查结果 | |
| 110 | + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult()); | |
| 111 | + twinsPatientsResult.setScreenResult(screenStr); | |
| 112 | + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); | |
| 113 | + stopWatch.start("query ant count"); | |
| 114 | + antExChuQuery1.setPid(patients.getPid()); | |
| 115 | + //antExChuQuery1.setParentId(patients.getId()); | |
| 116 | + //增加查询本次产程条数 | |
| 117 | + antExChuQuery1.setStart(patients.getLastMenses()); | |
| 118 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
| 119 | + //复诊次数 | |
| 120 | + List<AntenatalExaminationModel> ant = null; | |
| 121 | + if (CollectionUtils.isNotEmpty(chu)) { | |
| 122 | + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院 | |
| 123 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 124 | + if (a.getHospitalId().equals(hospital)) { | |
| 125 | + twinsPatientsResult.setYi("本院"); | |
| 126 | + } else { | |
| 127 | + twinsPatientsResult.setYi("外院"); | |
| 128 | + } | |
| 129 | + break; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
| 133 | + } | |
| 134 | + | |
| 135 | + //唐山滦县判断复诊是否是本院 | |
| 136 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 137 | + for (int k = 0; k < ant.size(); k++) { | |
| 138 | + if (k >= 4) { | |
| 139 | + break; | |
| 140 | + } | |
| 141 | + if (0 == k) { | |
| 142 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 143 | + twinsPatientsResult.setEr("本院"); | |
| 144 | + } else { | |
| 145 | + twinsPatientsResult.setEr("外院"); | |
| 146 | + } | |
| 147 | + } else if (1 == k) { | |
| 148 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 149 | + twinsPatientsResult.setSan("本院"); | |
| 150 | + } else { | |
| 151 | + twinsPatientsResult.setSan("外院"); | |
| 152 | + } | |
| 153 | + } else if (2 == k) { | |
| 154 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 155 | + twinsPatientsResult.setSi("本院"); | |
| 156 | + } else { | |
| 157 | + twinsPatientsResult.setSi("外院"); | |
| 158 | + } | |
| 159 | + } else if (3 == k) { | |
| 160 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 161 | + twinsPatientsResult.setWu("本院"); | |
| 162 | + } else { | |
| 163 | + twinsPatientsResult.setWu("外院"); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + //系统初诊次数 | |
| 170 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
| 171 | + | |
| 172 | + //系统复诊次数 | |
| 173 | + int i = 0; | |
| 174 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 175 | + //复诊次数 | |
| 176 | + i = ant.size(); | |
| 177 | + sort(ant); | |
| 178 | + for (AntenatalExaminationModel a : ant) { | |
| 179 | + try { | |
| 180 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 181 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 182 | + if (null != og) { | |
| 183 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 184 | + break; | |
| 185 | + } | |
| 186 | + } | |
| 187 | + } catch (Exception e) { | |
| 188 | + twinsPatientsResult.setCurrentCh(""); | |
| 189 | + } | |
| 190 | + } | |
| 191 | + } else { | |
| 192 | + for (AntExChuModel a : chu) { | |
| 193 | + try { | |
| 194 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 195 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 196 | + if (null != og) { | |
| 197 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 198 | + break; | |
| 199 | + } | |
| 200 | + } | |
| 201 | + } catch (Exception e) { | |
| 202 | + twinsPatientsResult.setCurrentCh(""); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + twinsPatientsResult.setcTimes(i + ichu); | |
| 208 | + | |
| 209 | + | |
| 210 | + antExQuery.setHospitalId(hospital); | |
| 211 | + //本院初诊 | |
| 212 | + int chi = countAntChu(chu, hospital); | |
| 213 | + | |
| 214 | + //本院复诊 | |
| 215 | + int chb = capLocalHospital(hospital, ant); | |
| 216 | + twinsPatientsResult.setcHTimes(chi + chb); | |
| 217 | + stopWatch.stop(); | |
| 218 | + String nextCheckTime = ""; | |
| 219 | + stopWatch.start("query antex list"); | |
| 220 | + | |
| 221 | + | |
| 222 | + if (null != patients.getNextCheckTime()) { | |
| 223 | + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime()); | |
| 224 | + } | |
| 225 | + | |
| 226 | + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 227 | + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 228 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 229 | + if (null != users) { | |
| 230 | + twinsPatientsResult.setCheckDoctor(users.getName()); | |
| 231 | + } else { | |
| 232 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 233 | + } | |
| 234 | + } else { | |
| 235 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 236 | + } | |
| 237 | + } | |
| 238 | + | |
| 239 | + | |
| 240 | + stopWatch.stop(); | |
| 241 | + stopWatch.start("query basicconfig"); | |
| 242 | + //注册地址 | |
| 243 | + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService)); | |
| 244 | + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
| 245 | + try { | |
| 246 | + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName()); | |
| 247 | + } catch (Exception e) { | |
| 248 | + twinsPatientsResult.setFirstBH(""); | |
| 249 | + } | |
| 250 | + | |
| 251 | + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 252 | + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 253 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 254 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 255 | +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 256 | + twinsPatientsResult.setcTime(nextCheckTime); | |
| 257 | + | |
| 258 | + | |
| 259 | + //高危因素 | |
| 260 | + List<String> factor = patients.getRiskFactorId(); | |
| 261 | + | |
| 262 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 263 | + StringBuilder sb = new StringBuilder(56); | |
| 264 | + for (String srt : factor) { | |
| 265 | + if (StringUtils.isNotEmpty(srt)) { | |
| 266 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 267 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 268 | + if("妊娠期高血压疾病(除外红、橙色)".equals(basicConfig.getName()) | |
| 269 | + ||"妊娠期高血压".equals(basicConfig.getName()) | |
| 270 | + ||"子痫前期(轻)".equals(basicConfig.getName()) | |
| 271 | + ||"慢性高血压合并妊娠".equals(basicConfig.getName()) | |
| 272 | + ||"妊娠期高血压性心脏病".equals(basicConfig.getName()) | |
| 273 | + ||"急性肾脏疾病伴高血压".equals(basicConfig.getName()) | |
| 274 | + ||"慢性肾脏疾病伴高血压".equals(basicConfig.getName()) | |
| 275 | + ){ | |
| 276 | + sb.append(basicConfig.getName()).append(','); | |
| 277 | + } | |
| 278 | + } | |
| 279 | + } | |
| 280 | + } | |
| 281 | + if (sb.toString().endsWith(",")) { | |
| 282 | + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 283 | + } else { | |
| 284 | + twinsPatientsResult.setrFactor(sb.toString()); | |
| 285 | + } | |
| 286 | + | |
| 287 | + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 288 | + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor()); | |
| 289 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 290 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 291 | + }*/ | |
| 292 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 293 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 294 | + } | |
| 295 | + List level = new ArrayList(); | |
| 296 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 297 | + try { | |
| 298 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 299 | + for (String str : list) { | |
| 300 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 301 | + if (null != basicConfig) { | |
| 302 | + Map map = new HashMap(); | |
| 303 | + basicConfig.replenRisk(map); | |
| 304 | + // String name = basicConfig.getName(); | |
| 305 | + // if (name.indexOf("预警") > -1) { | |
| 306 | + // name = name.replace("预警", ""); | |
| 307 | + // } | |
| 308 | + // map.put("name", name); | |
| 309 | + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 310 | + level.add(map); | |
| 311 | + } | |
| 312 | + } | |
| 313 | + } catch (Exception e) { | |
| 314 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 315 | + } | |
| 316 | + twinsPatientsResult.setrLevel(HighScoreResult.filter(level)); | |
| 317 | + } | |
| 318 | + data.add(twinsPatientsResult); | |
| 319 | + stopWatch.stop(); | |
| 320 | + logger.debug(stopWatch.toString()); | |
| 321 | + } | |
| 322 | + return data; | |
| 323 | + } | |
| 324 | + | |
| 325 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
| 326 | + if (CollectionUtils.isEmpty(list)) { | |
| 327 | + return 0; | |
| 328 | + } | |
| 329 | + int count = 0; | |
| 330 | + for (AntenatalExaminationModel model : list) { | |
| 331 | + if (model.getHospitalId().equals(hospitalId)) { | |
| 332 | + count++; | |
| 333 | + } | |
| 334 | + } | |
| 335 | + return count; | |
| 336 | + } | |
| 337 | + | |
| 338 | + //统计复查里面的本院检查数 | |
| 339 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
| 340 | + int count = 0; | |
| 341 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
| 342 | + return count; | |
| 343 | + } | |
| 344 | + for (AntExChuModel model : list) { | |
| 345 | + if (hospital.equals(model.getHospitalId())) { | |
| 346 | + count++; | |
| 347 | + } | |
| 348 | + } | |
| 349 | + return count; | |
| 350 | + } | |
| 351 | + | |
| 352 | + private void sort(List<AntenatalExaminationModel> list) { | |
| 353 | + if (CollectionUtils.isEmpty(list)) { | |
| 354 | + return; | |
| 355 | + } | |
| 356 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
| 357 | + @Override | |
| 358 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
| 359 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
| 360 | + return 1; | |
| 361 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
| 362 | + return -1; | |
| 363 | + } | |
| 364 | + return 0; | |
| 365 | + } | |
| 366 | + }); | |
| 367 | + } | |
| 368 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/BloodSugarPatientWorker.java
View file @
ae2adb2
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.PatientsService; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; | |
| 14 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 15 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 16 | +import com.lyms.platform.operate.web.result.TwinsPatientsResult; | |
| 17 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
| 18 | +import com.lyms.platform.permission.model.Organization; | |
| 19 | +import com.lyms.platform.permission.model.Users; | |
| 20 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 21 | +import com.lyms.platform.permission.service.UsersService; | |
| 22 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 23 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 24 | +import com.lyms.platform.pojo.BasicConfig; | |
| 25 | +import com.lyms.platform.pojo.Patients; | |
| 26 | +import com.lyms.platform.query.AntExChuQuery; | |
| 27 | +import com.lyms.platform.query.AntExQuery; | |
| 28 | +import org.apache.commons.collections.CollectionUtils; | |
| 29 | +import org.apache.commons.lang.StringUtils; | |
| 30 | +import org.apache.commons.lang.math.NumberUtils; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.util.StopWatch; | |
| 34 | + | |
| 35 | +import java.util.*; | |
| 36 | +import java.util.concurrent.Callable; | |
| 37 | + | |
| 38 | +/** | |
| 39 | + * 全部孕妇列表 | |
| 40 | + */ | |
| 41 | +public class BloodSugarPatientWorker implements Callable<List<QuanPatientsResult>> { | |
| 42 | + | |
| 43 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 44 | + | |
| 45 | + private List<Patients> patientses; | |
| 46 | + | |
| 47 | + private String hospital; | |
| 48 | + private UsersService usersService; | |
| 49 | + private AntenatalExaminationService antExService; | |
| 50 | + private BasicConfigService basicConfigService; | |
| 51 | + private PatientsService patientsService; | |
| 52 | + private OrganizationService organizationService; | |
| 53 | + private RiskPatientsQueryRequest riskPatientsQueryRequest; | |
| 54 | + | |
| 55 | + public BloodSugarPatientWorker(RiskPatientsQueryRequest riskPatientsQueryRequest, | |
| 56 | + List<Patients> patientses, | |
| 57 | + UsersService usersService, | |
| 58 | + String hospital, | |
| 59 | + AntenatalExaminationService antExService, | |
| 60 | + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) { | |
| 61 | + this.riskPatientsQueryRequest = riskPatientsQueryRequest; | |
| 62 | + this.patientses = patientses; | |
| 63 | + this.usersService = usersService; | |
| 64 | + this.antExService = antExService; | |
| 65 | + this.hospital = hospital; | |
| 66 | + this.basicConfigService = basicConfigService; | |
| 67 | + this.patientsService = patientsService; | |
| 68 | + this.organizationService = organizationService; | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public List<QuanPatientsResult> call() throws Exception { | |
| 73 | + List data = new ArrayList<>(); | |
| 74 | + AntExQuery antExQuery = new AntExQuery(); | |
| 75 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 76 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
| 77 | + | |
| 78 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
| 79 | + String twinsType = ""; | |
| 80 | + if(StringUtils.isNotEmpty(riskPatientsQueryRequest.getTwinsType())){ | |
| 81 | + twinsType = riskPatientsQueryRequest.getTwinsType(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + for (Patients patients : patientses) { | |
| 85 | + | |
| 86 | + StopWatch stopWatch = new StopWatch("TwinsPatientWorker -" + patients.getId()); | |
| 87 | + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult(); | |
| 88 | + twinsPatientsResult.setYi("-"); | |
| 89 | + twinsPatientsResult.setEr("-"); | |
| 90 | + twinsPatientsResult.setSan("-"); | |
| 91 | + twinsPatientsResult.setSi("-"); | |
| 92 | + twinsPatientsResult.setWu("-"); | |
| 93 | + twinsPatientsResult.convertToResult(patients); | |
| 94 | + antExQuery.setPid(patients.getPid()); | |
| 95 | + //增加查询本次产程条数 | |
| 96 | + antExQuery.setStart(patients.getLastMenses()); | |
| 97 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 98 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 99 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 100 | + if (null != users) { | |
| 101 | + twinsPatientsResult.setlName(users.getName()); | |
| 102 | + } else { | |
| 103 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 104 | + } | |
| 105 | + } else { | |
| 106 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + //筛查结果 | |
| 110 | + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult()); | |
| 111 | + twinsPatientsResult.setScreenResult(screenStr); | |
| 112 | + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); | |
| 113 | + stopWatch.start("query ant count"); | |
| 114 | + antExChuQuery1.setPid(patients.getPid()); | |
| 115 | + //antExChuQuery1.setParentId(patients.getId()); | |
| 116 | + //增加查询本次产程条数 | |
| 117 | + antExChuQuery1.setStart(patients.getLastMenses()); | |
| 118 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
| 119 | + //复诊次数 | |
| 120 | + List<AntenatalExaminationModel> ant = null; | |
| 121 | + if (CollectionUtils.isNotEmpty(chu)) { | |
| 122 | + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院 | |
| 123 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 124 | + if (a.getHospitalId().equals(hospital)) { | |
| 125 | + twinsPatientsResult.setYi("本院"); | |
| 126 | + } else { | |
| 127 | + twinsPatientsResult.setYi("外院"); | |
| 128 | + } | |
| 129 | + break; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
| 133 | + } | |
| 134 | + | |
| 135 | + //唐山滦县判断复诊是否是本院 | |
| 136 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 137 | + for (int k = 0; k < ant.size(); k++) { | |
| 138 | + if (k >= 4) { | |
| 139 | + break; | |
| 140 | + } | |
| 141 | + if (0 == k) { | |
| 142 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 143 | + twinsPatientsResult.setEr("本院"); | |
| 144 | + } else { | |
| 145 | + twinsPatientsResult.setEr("外院"); | |
| 146 | + } | |
| 147 | + } else if (1 == k) { | |
| 148 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 149 | + twinsPatientsResult.setSan("本院"); | |
| 150 | + } else { | |
| 151 | + twinsPatientsResult.setSan("外院"); | |
| 152 | + } | |
| 153 | + } else if (2 == k) { | |
| 154 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 155 | + twinsPatientsResult.setSi("本院"); | |
| 156 | + } else { | |
| 157 | + twinsPatientsResult.setSi("外院"); | |
| 158 | + } | |
| 159 | + } else if (3 == k) { | |
| 160 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 161 | + twinsPatientsResult.setWu("本院"); | |
| 162 | + } else { | |
| 163 | + twinsPatientsResult.setWu("外院"); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + //系统初诊次数 | |
| 170 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
| 171 | + | |
| 172 | + //系统复诊次数 | |
| 173 | + int i = 0; | |
| 174 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 175 | + //复诊次数 | |
| 176 | + i = ant.size(); | |
| 177 | + sort(ant); | |
| 178 | + for (AntenatalExaminationModel a : ant) { | |
| 179 | + try { | |
| 180 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 181 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 182 | + if (null != og) { | |
| 183 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 184 | + break; | |
| 185 | + } | |
| 186 | + } | |
| 187 | + } catch (Exception e) { | |
| 188 | + twinsPatientsResult.setCurrentCh(""); | |
| 189 | + } | |
| 190 | + } | |
| 191 | + } else { | |
| 192 | + for (AntExChuModel a : chu) { | |
| 193 | + try { | |
| 194 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 195 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 196 | + if (null != og) { | |
| 197 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 198 | + break; | |
| 199 | + } | |
| 200 | + } | |
| 201 | + } catch (Exception e) { | |
| 202 | + twinsPatientsResult.setCurrentCh(""); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + twinsPatientsResult.setcTimes(i + ichu); | |
| 208 | + | |
| 209 | + | |
| 210 | + antExQuery.setHospitalId(hospital); | |
| 211 | + //本院初诊 | |
| 212 | + int chi = countAntChu(chu, hospital); | |
| 213 | + | |
| 214 | + //本院复诊 | |
| 215 | + int chb = capLocalHospital(hospital, ant); | |
| 216 | + twinsPatientsResult.setcHTimes(chi + chb); | |
| 217 | + stopWatch.stop(); | |
| 218 | + String nextCheckTime = ""; | |
| 219 | + stopWatch.start("query antex list"); | |
| 220 | + | |
| 221 | + | |
| 222 | + if (null != patients.getNextCheckTime()) { | |
| 223 | + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime()); | |
| 224 | + } | |
| 225 | + | |
| 226 | + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 227 | + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 228 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 229 | + if (null != users) { | |
| 230 | + twinsPatientsResult.setCheckDoctor(users.getName()); | |
| 231 | + } else { | |
| 232 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 233 | + } | |
| 234 | + } else { | |
| 235 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 236 | + } | |
| 237 | + } | |
| 238 | + | |
| 239 | + | |
| 240 | + stopWatch.stop(); | |
| 241 | + stopWatch.start("query basicconfig"); | |
| 242 | + //注册地址 | |
| 243 | + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService)); | |
| 244 | + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
| 245 | + try { | |
| 246 | + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName()); | |
| 247 | + } catch (Exception e) { | |
| 248 | + twinsPatientsResult.setFirstBH(""); | |
| 249 | + } | |
| 250 | + | |
| 251 | + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 252 | + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 253 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 254 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 255 | +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 256 | + twinsPatientsResult.setcTime(nextCheckTime); | |
| 257 | + | |
| 258 | + | |
| 259 | + //高危因素 | |
| 260 | + List<String> factor = patients.getRiskFactorId(); | |
| 261 | + | |
| 262 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 263 | + StringBuilder sb = new StringBuilder(56); | |
| 264 | + for (String srt : factor) { | |
| 265 | + if (StringUtils.isNotEmpty(srt)) { | |
| 266 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 267 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 268 | + if("妊娠期糖尿病(无需药物治疗)".equals(basicConfig.getName()) | |
| 269 | + ||"妊娠期糖尿病病史".equals(basicConfig.getName()) | |
| 270 | + ||"糖尿病合并妊娠(无需药物治疗)".equals(basicConfig.getName()) | |
| 271 | + ||"糖尿病并发肾病V级、严重心血管病、增生性视网膜病变或玻璃体出血、周围神经病变等".equals(basicConfig.getName()) | |
| 272 | + ||"糖尿病并发肾病V级".equals(basicConfig.getName()) | |
| 273 | + ||"糖尿病并发严重心血管病".equals(basicConfig.getName()) | |
| 274 | + ||"糖尿病并发增生性视网膜病变".equals(basicConfig.getName()) | |
| 275 | + ||"糖尿病并发玻璃体出血".equals(basicConfig.getName()) | |
| 276 | + ||"糖尿病并发周围神经病变等".equals(basicConfig.getName()) | |
| 277 | + ){ | |
| 278 | + sb.append(basicConfig.getName()).append(','); | |
| 279 | + } | |
| 280 | + } | |
| 281 | + } | |
| 282 | + } | |
| 283 | + if (sb.toString().endsWith(",")) { | |
| 284 | + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 285 | + } else { | |
| 286 | + twinsPatientsResult.setrFactor(sb.toString()); | |
| 287 | + } | |
| 288 | + | |
| 289 | + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 290 | + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor()); | |
| 291 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 292 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 293 | + }*/ | |
| 294 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 295 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 296 | + } | |
| 297 | + List level = new ArrayList(); | |
| 298 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 299 | + try { | |
| 300 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 301 | + for (String str : list) { | |
| 302 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 303 | + if (null != basicConfig) { | |
| 304 | + Map map = new HashMap(); | |
| 305 | + basicConfig.replenRisk(map); | |
| 306 | + // String name = basicConfig.getName(); | |
| 307 | + // if (name.indexOf("预警") > -1) { | |
| 308 | + // name = name.replace("预警", ""); | |
| 309 | + // } | |
| 310 | + // map.put("name", name); | |
| 311 | + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 312 | + level.add(map); | |
| 313 | + } | |
| 314 | + } | |
| 315 | + } catch (Exception e) { | |
| 316 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 317 | + } | |
| 318 | + twinsPatientsResult.setrLevel(HighScoreResult.filter(level)); | |
| 319 | + } | |
| 320 | + data.add(twinsPatientsResult); | |
| 321 | + stopWatch.stop(); | |
| 322 | + logger.debug(stopWatch.toString()); | |
| 323 | + } | |
| 324 | + return data; | |
| 325 | + } | |
| 326 | + | |
| 327 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
| 328 | + if (CollectionUtils.isEmpty(list)) { | |
| 329 | + return 0; | |
| 330 | + } | |
| 331 | + int count = 0; | |
| 332 | + for (AntenatalExaminationModel model : list) { | |
| 333 | + if (model.getHospitalId().equals(hospitalId)) { | |
| 334 | + count++; | |
| 335 | + } | |
| 336 | + } | |
| 337 | + return count; | |
| 338 | + } | |
| 339 | + | |
| 340 | + //统计复查里面的本院检查数 | |
| 341 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
| 342 | + int count = 0; | |
| 343 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
| 344 | + return count; | |
| 345 | + } | |
| 346 | + for (AntExChuModel model : list) { | |
| 347 | + if (hospital.equals(model.getHospitalId())) { | |
| 348 | + count++; | |
| 349 | + } | |
| 350 | + } | |
| 351 | + return count; | |
| 352 | + } | |
| 353 | + | |
| 354 | + private void sort(List<AntenatalExaminationModel> list) { | |
| 355 | + if (CollectionUtils.isEmpty(list)) { | |
| 356 | + return; | |
| 357 | + } | |
| 358 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
| 359 | + @Override | |
| 360 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
| 361 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
| 362 | + return 1; | |
| 363 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
| 364 | + return -1; | |
| 365 | + } | |
| 366 | + return 0; | |
| 367 | + } | |
| 368 | + }); | |
| 369 | + } | |
| 370 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/ScarUterusPatientWorker.java
View file @
ae2adb2
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.PatientsService; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; | |
| 14 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 15 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 16 | +import com.lyms.platform.operate.web.result.TwinsPatientsResult; | |
| 17 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
| 18 | +import com.lyms.platform.permission.model.Organization; | |
| 19 | +import com.lyms.platform.permission.model.Users; | |
| 20 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 21 | +import com.lyms.platform.permission.service.UsersService; | |
| 22 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 23 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 24 | +import com.lyms.platform.pojo.BasicConfig; | |
| 25 | +import com.lyms.platform.pojo.Patients; | |
| 26 | +import com.lyms.platform.query.AntExChuQuery; | |
| 27 | +import com.lyms.platform.query.AntExQuery; | |
| 28 | +import org.apache.commons.collections.CollectionUtils; | |
| 29 | +import org.apache.commons.lang.StringUtils; | |
| 30 | +import org.apache.commons.lang.math.NumberUtils; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.util.StopWatch; | |
| 34 | + | |
| 35 | +import java.util.*; | |
| 36 | +import java.util.concurrent.Callable; | |
| 37 | + | |
| 38 | +/** | |
| 39 | + * 全部孕妇列表 | |
| 40 | + */ | |
| 41 | +public class ScarUterusPatientWorker implements Callable<List<QuanPatientsResult>> { | |
| 42 | + | |
| 43 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 44 | + | |
| 45 | + private List<Patients> patientses; | |
| 46 | + | |
| 47 | + private String hospital; | |
| 48 | + private UsersService usersService; | |
| 49 | + private AntenatalExaminationService antExService; | |
| 50 | + private BasicConfigService basicConfigService; | |
| 51 | + private PatientsService patientsService; | |
| 52 | + private OrganizationService organizationService; | |
| 53 | + private RiskPatientsQueryRequest riskPatientsQueryRequest; | |
| 54 | + | |
| 55 | + public ScarUterusPatientWorker(RiskPatientsQueryRequest riskPatientsQueryRequest, | |
| 56 | + List<Patients> patientses, | |
| 57 | + UsersService usersService, | |
| 58 | + String hospital, | |
| 59 | + AntenatalExaminationService antExService, | |
| 60 | + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) { | |
| 61 | + this.riskPatientsQueryRequest = riskPatientsQueryRequest; | |
| 62 | + this.patientses = patientses; | |
| 63 | + this.usersService = usersService; | |
| 64 | + this.antExService = antExService; | |
| 65 | + this.hospital = hospital; | |
| 66 | + this.basicConfigService = basicConfigService; | |
| 67 | + this.patientsService = patientsService; | |
| 68 | + this.organizationService = organizationService; | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public List<QuanPatientsResult> call() throws Exception { | |
| 73 | + List data = new ArrayList<>(); | |
| 74 | + AntExQuery antExQuery = new AntExQuery(); | |
| 75 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 76 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
| 77 | + | |
| 78 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
| 79 | + String twinsType = ""; | |
| 80 | + if(StringUtils.isNotEmpty(riskPatientsQueryRequest.getTwinsType())){ | |
| 81 | + twinsType = riskPatientsQueryRequest.getTwinsType(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + for (Patients patients : patientses) { | |
| 85 | + | |
| 86 | + StopWatch stopWatch = new StopWatch("TwinsPatientWorker -" + patients.getId()); | |
| 87 | + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult(); | |
| 88 | + twinsPatientsResult.setYi("-"); | |
| 89 | + twinsPatientsResult.setEr("-"); | |
| 90 | + twinsPatientsResult.setSan("-"); | |
| 91 | + twinsPatientsResult.setSi("-"); | |
| 92 | + twinsPatientsResult.setWu("-"); | |
| 93 | + twinsPatientsResult.convertToResult(patients); | |
| 94 | + antExQuery.setPid(patients.getPid()); | |
| 95 | + //增加查询本次产程条数 | |
| 96 | + antExQuery.setStart(patients.getLastMenses()); | |
| 97 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 98 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 99 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 100 | + if (null != users) { | |
| 101 | + twinsPatientsResult.setlName(users.getName()); | |
| 102 | + } else { | |
| 103 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 104 | + } | |
| 105 | + } else { | |
| 106 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + //筛查结果 | |
| 110 | + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult()); | |
| 111 | + twinsPatientsResult.setScreenResult(screenStr); | |
| 112 | + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); | |
| 113 | + stopWatch.start("query ant count"); | |
| 114 | + antExChuQuery1.setPid(patients.getPid()); | |
| 115 | + //antExChuQuery1.setParentId(patients.getId()); | |
| 116 | + //增加查询本次产程条数 | |
| 117 | + antExChuQuery1.setStart(patients.getLastMenses()); | |
| 118 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
| 119 | + //复诊次数 | |
| 120 | + List<AntenatalExaminationModel> ant = null; | |
| 121 | + if (CollectionUtils.isNotEmpty(chu)) { | |
| 122 | + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院 | |
| 123 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 124 | + if (a.getHospitalId().equals(hospital)) { | |
| 125 | + twinsPatientsResult.setYi("本院"); | |
| 126 | + } else { | |
| 127 | + twinsPatientsResult.setYi("外院"); | |
| 128 | + } | |
| 129 | + break; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
| 133 | + } | |
| 134 | + | |
| 135 | + //唐山滦县判断复诊是否是本院 | |
| 136 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 137 | + for (int k = 0; k < ant.size(); k++) { | |
| 138 | + if (k >= 4) { | |
| 139 | + break; | |
| 140 | + } | |
| 141 | + if (0 == k) { | |
| 142 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 143 | + twinsPatientsResult.setEr("本院"); | |
| 144 | + } else { | |
| 145 | + twinsPatientsResult.setEr("外院"); | |
| 146 | + } | |
| 147 | + } else if (1 == k) { | |
| 148 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 149 | + twinsPatientsResult.setSan("本院"); | |
| 150 | + } else { | |
| 151 | + twinsPatientsResult.setSan("外院"); | |
| 152 | + } | |
| 153 | + } else if (2 == k) { | |
| 154 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 155 | + twinsPatientsResult.setSi("本院"); | |
| 156 | + } else { | |
| 157 | + twinsPatientsResult.setSi("外院"); | |
| 158 | + } | |
| 159 | + } else if (3 == k) { | |
| 160 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 161 | + twinsPatientsResult.setWu("本院"); | |
| 162 | + } else { | |
| 163 | + twinsPatientsResult.setWu("外院"); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + //系统初诊次数 | |
| 170 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
| 171 | + | |
| 172 | + //系统复诊次数 | |
| 173 | + int i = 0; | |
| 174 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 175 | + //复诊次数 | |
| 176 | + i = ant.size(); | |
| 177 | + sort(ant); | |
| 178 | + for (AntenatalExaminationModel a : ant) { | |
| 179 | + try { | |
| 180 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 181 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 182 | + if (null != og) { | |
| 183 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 184 | + break; | |
| 185 | + } | |
| 186 | + } | |
| 187 | + } catch (Exception e) { | |
| 188 | + twinsPatientsResult.setCurrentCh(""); | |
| 189 | + } | |
| 190 | + } | |
| 191 | + } else { | |
| 192 | + for (AntExChuModel a : chu) { | |
| 193 | + try { | |
| 194 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 195 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 196 | + if (null != og) { | |
| 197 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 198 | + break; | |
| 199 | + } | |
| 200 | + } | |
| 201 | + } catch (Exception e) { | |
| 202 | + twinsPatientsResult.setCurrentCh(""); | |
| 203 | + } | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + twinsPatientsResult.setcTimes(i + ichu); | |
| 208 | + | |
| 209 | + | |
| 210 | + antExQuery.setHospitalId(hospital); | |
| 211 | + //本院初诊 | |
| 212 | + int chi = countAntChu(chu, hospital); | |
| 213 | + | |
| 214 | + //本院复诊 | |
| 215 | + int chb = capLocalHospital(hospital, ant); | |
| 216 | + twinsPatientsResult.setcHTimes(chi + chb); | |
| 217 | + stopWatch.stop(); | |
| 218 | + String nextCheckTime = ""; | |
| 219 | + stopWatch.start("query antex list"); | |
| 220 | + | |
| 221 | + | |
| 222 | + if (null != patients.getNextCheckTime()) { | |
| 223 | + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime()); | |
| 224 | + } | |
| 225 | + | |
| 226 | + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 227 | + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 228 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 229 | + if (null != users) { | |
| 230 | + twinsPatientsResult.setCheckDoctor(users.getName()); | |
| 231 | + } else { | |
| 232 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 233 | + } | |
| 234 | + } else { | |
| 235 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 236 | + } | |
| 237 | + } | |
| 238 | + | |
| 239 | + | |
| 240 | + stopWatch.stop(); | |
| 241 | + stopWatch.start("query basicconfig"); | |
| 242 | + //注册地址 | |
| 243 | + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService)); | |
| 244 | + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
| 245 | + try { | |
| 246 | + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName()); | |
| 247 | + } catch (Exception e) { | |
| 248 | + twinsPatientsResult.setFirstBH(""); | |
| 249 | + } | |
| 250 | + | |
| 251 | + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 252 | + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 253 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 254 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 255 | +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 256 | + twinsPatientsResult.setcTime(nextCheckTime); | |
| 257 | + | |
| 258 | + | |
| 259 | + //高危因素 | |
| 260 | + List<String> factor = patients.getRiskFactorId(); | |
| 261 | + | |
| 262 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 263 | + StringBuilder sb = new StringBuilder(56); | |
| 264 | + for (String srt : factor) { | |
| 265 | + if (StringUtils.isNotEmpty(srt)) { | |
| 266 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 267 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 268 | + if("瘢痕子宫".equals(basicConfig.getName()) | |
| 269 | + ||"剖宫产1次".equals(basicConfig.getName()) | |
| 270 | + ||"子宫肌瘤挖出术1次".equals(basicConfig.getName()) | |
| 271 | + ||"宫角妊娠1次".equals(basicConfig.getName()) | |
| 272 | + ||"瘢痕子宫(距末次子宫手术间隔<18月)".equals(basicConfig.getName()) | |
| 273 | + ||"疤痕子宫伴中央性前置胎盘或伴有可疑胎盘植入".equals(basicConfig.getName()) | |
| 274 | + ||"瘢痕子宫伴中央性前置胎盘".equals(basicConfig.getName()) | |
| 275 | + ||"瘢痕子宫伴有可疑胎盘植入".equals(basicConfig.getName()) | |
| 276 | + ||"各类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥2次".equals(basicConfig.getName()) | |
| 277 | + ||"宫角妊娠≥2次".equals(basicConfig.getName()) | |
| 278 | + ||"子宫肌瘤挖出术≥2次".equals(basicConfig.getName()) | |
| 279 | + ||"各类子宫手术史≥2次".equals(basicConfig.getName()) | |
| 280 | + ){ | |
| 281 | + sb.append(basicConfig.getName()).append(','); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + } | |
| 285 | + } | |
| 286 | + if (sb.toString().endsWith(",")) { | |
| 287 | + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 288 | + } else { | |
| 289 | + twinsPatientsResult.setrFactor(sb.toString()); | |
| 290 | + } | |
| 291 | + | |
| 292 | + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 293 | + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor()); | |
| 294 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 295 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 296 | + }*/ | |
| 297 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 298 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 299 | + } | |
| 300 | + List level = new ArrayList(); | |
| 301 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 302 | + try { | |
| 303 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 304 | + for (String str : list) { | |
| 305 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 306 | + if (null != basicConfig) { | |
| 307 | + Map map = new HashMap(); | |
| 308 | + basicConfig.replenRisk(map); | |
| 309 | + // String name = basicConfig.getName(); | |
| 310 | + // if (name.indexOf("预警") > -1) { | |
| 311 | + // name = name.replace("预警", ""); | |
| 312 | + // } | |
| 313 | + // map.put("name", name); | |
| 314 | + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 315 | + level.add(map); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + } catch (Exception e) { | |
| 319 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 320 | + } | |
| 321 | + twinsPatientsResult.setrLevel(HighScoreResult.filter(level)); | |
| 322 | + } | |
| 323 | + data.add(twinsPatientsResult); | |
| 324 | + stopWatch.stop(); | |
| 325 | + logger.debug(stopWatch.toString()); | |
| 326 | + } | |
| 327 | + return data; | |
| 328 | + } | |
| 329 | + | |
| 330 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
| 331 | + if (CollectionUtils.isEmpty(list)) { | |
| 332 | + return 0; | |
| 333 | + } | |
| 334 | + int count = 0; | |
| 335 | + for (AntenatalExaminationModel model : list) { | |
| 336 | + if (model.getHospitalId().equals(hospitalId)) { | |
| 337 | + count++; | |
| 338 | + } | |
| 339 | + } | |
| 340 | + return count; | |
| 341 | + } | |
| 342 | + | |
| 343 | + //统计复查里面的本院检查数 | |
| 344 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
| 345 | + int count = 0; | |
| 346 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
| 347 | + return count; | |
| 348 | + } | |
| 349 | + for (AntExChuModel model : list) { | |
| 350 | + if (hospital.equals(model.getHospitalId())) { | |
| 351 | + count++; | |
| 352 | + } | |
| 353 | + } | |
| 354 | + return count; | |
| 355 | + } | |
| 356 | + | |
| 357 | + private void sort(List<AntenatalExaminationModel> list) { | |
| 358 | + if (CollectionUtils.isEmpty(list)) { | |
| 359 | + return; | |
| 360 | + } | |
| 361 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
| 362 | + @Override | |
| 363 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
| 364 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
| 365 | + return 1; | |
| 366 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
| 367 | + return -1; | |
| 368 | + } | |
| 369 | + return 0; | |
| 370 | + } | |
| 371 | + }); | |
| 372 | + } | |
| 373 | +} |