Commit 31d3f028758126d00c2316c7511d85e41595d226

Authored by zhangchao
1 parent d34e6349f6
Exists in dev

#fix:优化大同高危手册,新增对应字段及血液专病管理特殊处理

Showing 12 changed files with 754 additions and 7 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java View file @ 31d3f02
... ... @@ -131,7 +131,7 @@
131 131 patientsQuery.mysqlBuild(iPatientDao.queryPatientCount(query));
132 132 query.start(patientsQuery.getOffset()).end(patientsQuery.getLimit());
133 133 }
134   - System.out.println(query.convertToMongoQuery());
  134 + //System.out.println(query.convertToMongoQuery());
135 135 return iPatientDao.queryPatient(query.addOrder(Sort.Direction.fromString(sort), field));
136 136 }
137 137  
platform-dal/src/main/java/com/lyms/platform/pojo/AntExChuModel.java View file @ 31d3f02
... ... @@ -544,6 +544,34 @@
544 544 private Integer fuzhurenshen;//是否辅助妊娠 1是 0否
545 545 private String fuzhufangshi;//辅助方式
546 546  
  547 + private String other;//高危手册初诊其他
  548 + private String symptoms;//高危手册症状与体征
  549 + private String otherCheck;//高危手册其他检查项
  550 +
  551 + public String getOther() {
  552 + return other;
  553 + }
  554 +
  555 + public void setOther(String other) {
  556 + this.other = other;
  557 + }
  558 +
  559 + public String getSymptoms() {
  560 + return symptoms;
  561 + }
  562 +
  563 + public void setSymptoms(String symptoms) {
  564 + this.symptoms = symptoms;
  565 + }
  566 +
  567 + public String getOtherCheck() {
  568 + return otherCheck;
  569 + }
  570 +
  571 + public void setOtherCheck(String otherCheck) {
  572 + this.otherCheck = otherCheck;
  573 + }
  574 +
547 575 public String getYongyaoshi() {
548 576 return yongyaoshi;
549 577 }
platform-dal/src/main/java/com/lyms/platform/pojo/AntenatalExaminationModel.java View file @ 31d3f02
... ... @@ -421,6 +421,38 @@
421 421 //本次随访日期
422 422 private String followupDate;
423 423  
  424 +
  425 +
  426 + //大同高危手册
  427 + private String other;//高危手册初诊其他
  428 + private String symptoms;//高危手册症状与体征
  429 + private String otherCheck;//高危手册其他检查项
  430 +
  431 + public String getOther() {
  432 + return other;
  433 + }
  434 +
  435 + public void setOther(String other) {
  436 + this.other = other;
  437 + }
  438 +
  439 + public String getSymptoms() {
  440 + return symptoms;
  441 + }
  442 +
  443 + public void setSymptoms(String symptoms) {
  444 + this.symptoms = symptoms;
  445 + }
  446 +
  447 + public String getOtherCheck() {
  448 + return otherCheck;
  449 + }
  450 +
  451 + public void setOtherCheck(String otherCheck) {
  452 + this.otherCheck = otherCheck;
  453 + }
  454 +
  455 +
424 456 public Integer getIsAppCreate() {
425 457 return isAppCreate;
426 458 }
platform-dal/src/main/java/com/lyms/platform/pojo/MaternalDeliverModel.java View file @ 31d3f02
... ... @@ -236,6 +236,52 @@
236 236 */
237 237 private String cfyc;
238 238  
  239 + //大同高危手册
  240 + private String currentCondition;//本次孕期情况
  241 + private String pelvicCondition;//骨盆情况
  242 + private String babySize;//估计胎儿大小
  243 + private String dtDiagnosis;//门诊诊断
  244 + private String advice;//医生意见
  245 +
  246 + public String getCurrentCondition() {
  247 + return currentCondition;
  248 + }
  249 +
  250 + public void setCurrentCondition(String currentCondition) {
  251 + this.currentCondition = currentCondition;
  252 + }
  253 +
  254 + public String getPelvicCondition() {
  255 + return pelvicCondition;
  256 + }
  257 +
  258 + public void setPelvicCondition(String pelvicCondition) {
  259 + this.pelvicCondition = pelvicCondition;
  260 + }
  261 +
  262 + public String getBabySize() {
  263 + return babySize;
  264 + }
  265 +
  266 + public void setBabySize(String babySize) {
  267 + this.babySize = babySize;
  268 + }
  269 +
  270 + public String getDtDiagnosis() {
  271 + return dtDiagnosis;
  272 + }
  273 +
  274 + public void setDtDiagnosis(String dtDiagnosis) {
  275 + this.dtDiagnosis = dtDiagnosis;
  276 + }
  277 +
  278 + public String getAdvice() {
  279 + return advice;
  280 + }
  281 +
  282 + public void setAdvice(String advice) {
  283 + this.advice = advice;
  284 + }
239 285  
240 286 public String getFmddlb() {
241 287 return fmddlb;
platform-operate-api/src/main/java/com/lyms/hospitalapi/dtdyrm/DtdyrmFmService.java View file @ 31d3f02
... ... @@ -137,13 +137,15 @@
137 137 PersonModel resperson = personService.addPerson(pmodel);
138 138  
139 139 patient=new Patients();
  140 + patient.setIsAutoFm(0);
140 141 patient.setHospitalId(HOSPITALID);
141 142 patient.setFmHospital(HOSPITALID);
142 143 patient.setFmDate(new Date());
143 144 patient.setCardNo(allFm.getIdcard());
144 145 patient.setYn(1);
145 146 patient.setType(3);
146   - patient.setBookbuildingDate(new Date());
  147 + patient.setBuildType(2);
  148 + //patient.setBookbuildingDate(new Date());
147 149 //patient.setBookbuildingDoctor();
148 150 patient.setUsername(allFm.getName());
149 151 patient.setPhone(allFm.getPhone());
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java View file @ 31d3f02
... ... @@ -579,7 +579,7 @@
579 579  
580 580  
581 581 //根据疾病进行查询
582   - if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getDiseaseType())) {
  582 + if (!"2100002419".equals(hospital)&&StringUtils.isNotEmpty(riskPatientsQueryRequest.getDiseaseType())) {
583 583 MongoCondition criteria = new MongoCondition("hospitalId", hospital, MongoOper.IS);
584 584  
585 585 List <MongoCondition> mongoCondits = new ArrayList <>();
... ... @@ -1716,6 +1716,29 @@
1716 1716 return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo());
1717 1717 }
1718 1718  
  1719 + private List convertToRhRareList(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital){
  1720 + List data = new ArrayList <>();
  1721 + int batchSize = 4;
  1722 + int end = 0;
  1723 + List <Future> listFuture = new ArrayList <>();
  1724 + for (int i = 0; i < patientses.size(); i += batchSize) {
  1725 + end = (end + batchSize);
  1726 + if (end > patientses.size()) {
  1727 + end = patientses.size();
  1728 + }
  1729 + listFuture.add(commonThreadPool.submit(new RHWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService)));
  1730 + }
  1731 + for (Future f : listFuture) {
  1732 + try {
  1733 + data.addAll((List) f.get(30, TimeUnit.SECONDS));
  1734 + } catch (Exception e) {
  1735 + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error.");
  1736 + }
  1737 + }
  1738 + return data;
  1739 + }
  1740 +
  1741 +
1719 1742 private List convertToOldPatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) {
1720 1743 List data = new ArrayList <>();
1721 1744 int batchSize = 4;
1722 1745  
... ... @@ -1933,11 +1956,36 @@
1933 1956 }*/
1934 1957 //组合请求
1935 1958 PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion);
1936   - patientsQuery.setRareType("1");
1937 1959  
1938 1960 //查询符合条件的孕妇
1939 1961 StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital);
1940 1962 stopWatch.start();
  1963 + if ("2100002419".equals(hospital)){
  1964 + Query yn = null;
  1965 + String diseaseType=riskPatientsQueryRequest.getDiseaseType();
  1966 + if ("1,".equals(diseaseType)) {
  1967 + Criteria criteria1 = Criteria.where("name").is("RH(-)");
  1968 + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1));
  1969 + }else if ("2,".equals(diseaseType)){
  1970 + Criteria criteria1 = Criteria.where("name").is("Rh血型不合");
  1971 + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1));
  1972 +
  1973 + }else {
  1974 + Criteria criteria1 = Criteria.where("name").is("RH(-)");
  1975 + Criteria criteria2 = Criteria.where("name").is("Rh血型不合");
  1976 + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2));
  1977 + }
  1978 + List <BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class);
  1979 + List <String> rFactorList = new ArrayList <>();
  1980 + if (models != null && models.size() > 0) {
  1981 + for (int i = 0; i < models.size(); i++) {
  1982 + rFactorList.add(models.get(i).getId());
  1983 + }
  1984 + }
  1985 + patientsQuery.setrFactorList(rFactorList);
  1986 + }else {
  1987 + patientsQuery.setRareType("1");
  1988 + }
1941 1989 List <Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder());
1942 1990 stopWatch.stop();
1943 1991  
... ... @@ -1945,9 +1993,13 @@
1945 1993 List data = new ArrayList <QuanChanResult>();
1946 1994 if (CollectionUtils.isNotEmpty(patientses)) {
1947 1995 if (type == 1) {
1948   - //处理全部孕妇的情况
1949   - data = convertToRareList(riskPatientsQueryRequest, patientses, userId, hospital);
1950   -
  1996 + if ("2100002419".equals(hospital)){
  1997 + //大同做特殊处理查询RH(-)\Rh血型不合的高危因素
  1998 + data= convertToRhRareList(riskPatientsQueryRequest, patientses, userId, hospital);
  1999 + }else {
  2000 + //处理全部孕妇的情况
  2001 + data = convertToRareList(riskPatientsQueryRequest, patientses, userId, hospital);
  2002 + }
1951 2003 }
1952 2004 }
1953 2005 // patientsQuery.mysqlBuild(data.size());
... ... @@ -3237,6 +3289,7 @@
3237 3289 patientsQuery.setDueStatus(null==patientManagerRequest.getDueStatus() ? null : patientManagerRequest.getDueStatus());
3238 3290 patientsQuery.setType(patientManagerRequest.getType());
3239 3291 patientsQuery.setHighRiskFileCode(patientManagerRequest.getHighRiskFileCode());
  3292 + System.out.println(patientsQuery.convertToQuery().convertToMongoQuery().toString());
3240 3293 List <Patients> patientsList = patientsService.queryPatient(patientsQuery);
3241 3294 List <PatientManagerQueryModel> patientManagerQueryModelList = new ArrayList <>();
3242 3295 if (CollectionUtils.isNotEmpty(patientsList)) {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/AntExAddRequest.java View file @ 31d3f02
... ... @@ -436,6 +436,35 @@
436 436 private String height;
437 437 private String yqWeight;
438 438  
  439 + //大同高危手册专属
  440 + private String other;//高危手册初诊其他
  441 + private String symptoms;//高危手册症状与体征
  442 + private String otherCheck;//高危手册其他检查项
  443 +
  444 + public String getOther() {
  445 + return other;
  446 + }
  447 +
  448 + public void setOther(String other) {
  449 + this.other = other;
  450 + }
  451 +
  452 + public String getSymptoms() {
  453 + return symptoms;
  454 + }
  455 +
  456 + public void setSymptoms(String symptoms) {
  457 + this.symptoms = symptoms;
  458 + }
  459 +
  460 + public String getOtherCheck() {
  461 + return otherCheck;
  462 + }
  463 +
  464 + public void setOtherCheck(String otherCheck) {
  465 + this.otherCheck = otherCheck;
  466 + }
  467 +
439 468 public Integer getDoctorType() {
440 469 return doctorType;
441 470 }
... ... @@ -1670,6 +1699,10 @@
1670 1699 examinationModel.setFollowupDoctorName(followupDoctorName);
1671 1700 examinationModel.setName(name);
1672 1701 examinationModel.setFollowupDate(followupDate);
  1702 + examinationModel.setOther(other);
  1703 + examinationModel.setSymptoms(symptoms);
  1704 + examinationModel.setOtherCheck(otherCheck);
  1705 +
1673 1706 return examinationModel;
1674 1707 }
1675 1708  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/AntExcAddRequest.java View file @ 31d3f02
... ... @@ -561,6 +561,34 @@
561 561 private Integer fuzhurenshen;//是否辅助妊娠 1是 0否
562 562 private String fuzhufangshi;//辅助方式
563 563  
  564 + private String other;//高危手册初诊其他
  565 + private String symptoms;//高危手册症状与体征
  566 + private String otherCheck;//高危手册其他检查项
  567 +
  568 + public String getOther() {
  569 + return other;
  570 + }
  571 +
  572 + public void setOther(String other) {
  573 + this.other = other;
  574 + }
  575 +
  576 + public String getSymptoms() {
  577 + return symptoms;
  578 + }
  579 +
  580 + public void setSymptoms(String symptoms) {
  581 + this.symptoms = symptoms;
  582 + }
  583 +
  584 + public String getOtherCheck() {
  585 + return otherCheck;
  586 + }
  587 +
  588 + public void setOtherCheck(String otherCheck) {
  589 + this.otherCheck = otherCheck;
  590 + }
  591 +
564 592 public Integer getDoctorType() {
565 593 return doctorType;
566 594 }
... ... @@ -2723,6 +2751,9 @@
2723 2751 antExChuModel.setFollowupDoctorName(followupDoctorName);
2724 2752 antExChuModel.setName(name);
2725 2753 antExChuModel.setFollowupDate(followupDate);
  2754 + antExChuModel.setOther(other);
  2755 + antExChuModel.setSymptoms(symptoms);
  2756 + antExChuModel.setOtherCheck(otherCheck);
2726 2757 return antExChuModel;
2727 2758 }
2728 2759  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/MatDeliverAddRequest.java View file @ 31d3f02
... ... @@ -126,6 +126,57 @@
126 126  
127 127 private String inHospitalNo;
128 128  
  129 +
  130 +
  131 +
  132 + //大同高危手册
  133 + private String currentCondition;//本次孕期情况
  134 + private String pelvicCondition;//骨盆情况
  135 + private String babySize;//估计胎儿大小
  136 + private String dtDiagnosis;//门诊诊断
  137 + private String advice;//医生意见
  138 +
  139 +
  140 + public String getCurrentCondition() {
  141 + return currentCondition;
  142 + }
  143 +
  144 + public void setCurrentCondition(String currentCondition) {
  145 + this.currentCondition = currentCondition;
  146 + }
  147 +
  148 + public String getPelvicCondition() {
  149 + return pelvicCondition;
  150 + }
  151 +
  152 + public void setPelvicCondition(String pelvicCondition) {
  153 + this.pelvicCondition = pelvicCondition;
  154 + }
  155 +
  156 + public String getBabySize() {
  157 + return babySize;
  158 + }
  159 +
  160 + public void setBabySize(String babySize) {
  161 + this.babySize = babySize;
  162 + }
  163 +
  164 + public String getDtDiagnosis() {
  165 + return dtDiagnosis;
  166 + }
  167 +
  168 + public void setDtDiagnosis(String dtDiagnosis) {
  169 + this.dtDiagnosis = dtDiagnosis;
  170 + }
  171 +
  172 + public String getAdvice() {
  173 + return advice;
  174 + }
  175 +
  176 + public void setAdvice(String advice) {
  177 + this.advice = advice;
  178 + }
  179 +
129 180 public String getInHospitalNo() {
130 181 return inHospitalNo;
131 182 }
... ... @@ -631,6 +682,12 @@
631 682 maternalDeliverModel.setGwrs(gwrs);
632 683 maternalDeliverModel.setRsfxdm(rsfxdm);
633 684 maternalDeliverModel.setCfyc(cfyc);
  685 +
  686 + maternalDeliverModel.setCurrentCondition(currentCondition);
  687 + maternalDeliverModel.setPelvicCondition(pelvicCondition);
  688 + maternalDeliverModel.setAdvice(advice);
  689 + maternalDeliverModel.setBabySize(babySize);
  690 + maternalDeliverModel.setDtDiagnosis(dtDiagnosis);
634 691  
635 692 return maternalDeliverModel;
636 693 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/AntenatalExaminationResult.java View file @ 31d3f02
... ... @@ -124,6 +124,39 @@
124 124 private List<Integer> jmxspg;
125 125 private Integer jmxsScore;
126 126 private Integer jmxsLevel;
  127 +
  128 +
  129 +
  130 + //大同高危手册
  131 + private String other;//高危手册初诊其他
  132 + private String symptoms;//高危手册症状与体征
  133 + private String otherCheck;//高危手册其他检查项
  134 +
  135 + public String getOther() {
  136 + return other;
  137 + }
  138 +
  139 + public void setOther(String other) {
  140 + this.other = other;
  141 + }
  142 +
  143 + public String getSymptoms() {
  144 + return symptoms;
  145 + }
  146 +
  147 + public void setSymptoms(String symptoms) {
  148 + this.symptoms = symptoms;
  149 + }
  150 +
  151 + public String getOtherCheck() {
  152 + return otherCheck;
  153 + }
  154 +
  155 + public void setOtherCheck(String otherCheck) {
  156 + this.otherCheck = otherCheck;
  157 + }
  158 +
  159 +
127 160 public Integer getProductionSieveType() {
128 161 return productionSieveType;
129 162 }
... ... @@ -1463,6 +1496,9 @@
1463 1496 setFollowupDoctorName(destModel.getFollowupDoctorName());
1464 1497 setName(destModel.getName());
1465 1498 setFollowupDate(destModel.getFollowupDate());
  1499 + setOther(destModel.getOther());
  1500 + setSymptoms(destModel.getSymptoms());
  1501 + setOtherCheck(destModel.getOtherCheck());
1466 1502 return this;
1467 1503 }
1468 1504  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/MaternalDeliverResult.java View file @ 31d3f02
... ... @@ -102,6 +102,54 @@
102 102 //患者签名
103 103 private String patientSign;
104 104  
  105 +
  106 + //大同高危手册
  107 + private String currentCondition;//本次孕期情况
  108 + private String pelvicCondition;//骨盆情况
  109 + private String babySize;//估计胎儿大小
  110 + private String dtDiagnosis;//门诊诊断
  111 + private String advice;//医生意见
  112 +
  113 + public String getCurrentCondition() {
  114 + return currentCondition;
  115 + }
  116 +
  117 + public void setCurrentCondition(String currentCondition) {
  118 + this.currentCondition = currentCondition;
  119 + }
  120 +
  121 + public String getPelvicCondition() {
  122 + return pelvicCondition;
  123 + }
  124 +
  125 + public void setPelvicCondition(String pelvicCondition) {
  126 + this.pelvicCondition = pelvicCondition;
  127 + }
  128 +
  129 + public String getBabySize() {
  130 + return babySize;
  131 + }
  132 +
  133 + public void setBabySize(String babySize) {
  134 + this.babySize = babySize;
  135 + }
  136 +
  137 + public String getDtDiagnosis() {
  138 + return dtDiagnosis;
  139 + }
  140 +
  141 + public void setDtDiagnosis(String dtDiagnosis) {
  142 + this.dtDiagnosis = dtDiagnosis;
  143 + }
  144 +
  145 + public String getAdvice() {
  146 + return advice;
  147 + }
  148 +
  149 + public void setAdvice(String advice) {
  150 + this.advice = advice;
  151 + }
  152 +
105 153 public String getDoctorSign() {
106 154 return doctorSign;
107 155 }
... ... @@ -741,6 +789,13 @@
741 789 setGwrs(destModel.getGwrs());
742 790 setRsfxdm(destModel.getRsfxdm());
743 791 setCfyc(destModel.getCfyc());
  792 +
  793 + setBabySize(destModel.getBabySize());
  794 + setPerinealCondition(destModel.getPerinealCondition());
  795 + setCurrentCondition(destModel.getCurrentCondition());
  796 + setDtDiagnosis(destModel.getDtDiagnosis());
  797 + setAdvice(destModel.getAdvice());
  798 +
744 799 return this;
745 800 }
746 801  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/RHWorker.java View file @ 31d3f02
  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 +public class RHWorker implements Callable<List<QuanPatientsResult>> {
  39 + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class);
  40 +
  41 + private List<Patients> patientses;
  42 +
  43 + private String hospital;
  44 + private UsersService usersService;
  45 + private AntenatalExaminationService antExService;
  46 + private BasicConfigService basicConfigService;
  47 + private PatientsService patientsService;
  48 + private OrganizationService organizationService;
  49 + private RiskPatientsQueryRequest riskPatientsQueryRequest;
  50 +
  51 + public RHWorker(RiskPatientsQueryRequest riskPatientsQueryRequest,
  52 + List<Patients> patientses,
  53 + UsersService usersService,
  54 + String hospital,
  55 + AntenatalExaminationService antExService,
  56 + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) {
  57 + this.riskPatientsQueryRequest = riskPatientsQueryRequest;
  58 + this.patientses = patientses;
  59 + this.usersService = usersService;
  60 + this.antExService = antExService;
  61 + this.hospital = hospital;
  62 + this.basicConfigService = basicConfigService;
  63 + this.patientsService = patientsService;
  64 + this.organizationService = organizationService;
  65 + }
  66 +
  67 + @Override
  68 + public List<QuanPatientsResult> call() throws Exception {
  69 + List data = new ArrayList<>();
  70 + AntExQuery antExQuery = new AntExQuery();
  71 + antExQuery.setYn(YnEnums.YES.getId());
  72 + AntExChuQuery antExChuQuery1 = new AntExChuQuery();
  73 +
  74 + antExChuQuery1.setYn(YnEnums.YES.getId());
  75 + String twinsType = riskPatientsQueryRequest.getDiseaseType();
  76 +
  77 + for (Patients patients : patientses) {
  78 +
  79 + StopWatch stopWatch = new StopWatch("RHWorker -" + patients.getId());
  80 + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult();
  81 + twinsPatientsResult.setYi("-");
  82 + twinsPatientsResult.setEr("-");
  83 + twinsPatientsResult.setSan("-");
  84 + twinsPatientsResult.setSi("-");
  85 + twinsPatientsResult.setWu("-");
  86 + twinsPatientsResult.convertToResult(patients);
  87 + antExQuery.setPid(patients.getPid());
  88 + //增加查询本次产程条数
  89 + antExQuery.setStart(patients.getLastMenses());
  90 + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) {
  91 + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) {
  92 + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor()));
  93 + if (null != users) {
  94 + twinsPatientsResult.setlName(users.getName());
  95 + } else {
  96 + twinsPatientsResult.setlName(patients.getBookbuildingDoctor());
  97 + }
  98 + } else {
  99 + twinsPatientsResult.setlName(patients.getBookbuildingDoctor());
  100 + }
  101 + }
  102 + //筛查结果
  103 + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult());
  104 + twinsPatientsResult.setScreenResult(screenStr);
  105 + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate()));
  106 + stopWatch.start("query ant count");
  107 + antExChuQuery1.setPid(patients.getPid());
  108 + //antExChuQuery1.setParentId(patients.getId());
  109 + //增加查询本次产程条数
  110 + antExChuQuery1.setStart(patients.getLastMenses());
  111 + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery());
  112 + //复诊次数
  113 + List<AntenatalExaminationModel> ant = null;
  114 + if (CollectionUtils.isNotEmpty(chu)) {
  115 + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院
  116 + if (StringUtils.isNotEmpty(a.getHospitalId())) {
  117 + if (a.getHospitalId().equals(hospital)) {
  118 + twinsPatientsResult.setYi("本院");
  119 + } else {
  120 + twinsPatientsResult.setYi("外院");
  121 + }
  122 + break;
  123 + }
  124 + }
  125 + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery());
  126 + }
  127 +
  128 + //唐山滦县判断复诊是否是本院
  129 + if (CollectionUtils.isNotEmpty(ant)) {
  130 + for (int k = 0; k < ant.size(); k++) {
  131 + if (k >= 4) {
  132 + break;
  133 + }
  134 + if (0 == k) {
  135 + if (ant.get(k).getHospitalId().equals(hospital)) {
  136 + twinsPatientsResult.setEr("本院");
  137 + } else {
  138 + twinsPatientsResult.setEr("外院");
  139 + }
  140 + } else if (1 == k) {
  141 + if (ant.get(k).getHospitalId().equals(hospital)) {
  142 + twinsPatientsResult.setSan("本院");
  143 + } else {
  144 + twinsPatientsResult.setSan("外院");
  145 + }
  146 + } else if (2 == k) {
  147 + if (ant.get(k).getHospitalId().equals(hospital)) {
  148 + twinsPatientsResult.setSi("本院");
  149 + } else {
  150 + twinsPatientsResult.setSi("外院");
  151 + }
  152 + } else if (3 == k) {
  153 + if (ant.get(k).getHospitalId().equals(hospital)) {
  154 + twinsPatientsResult.setWu("本院");
  155 + } else {
  156 + twinsPatientsResult.setWu("外院");
  157 + }
  158 + }
  159 + }
  160 + }
  161 +
  162 + //系统初诊次数
  163 + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size();
  164 +
  165 + //系统复诊次数
  166 + int i = 0;
  167 + if (CollectionUtils.isNotEmpty(ant)) {
  168 + //复诊次数
  169 + i = ant.size();
  170 + sort(ant);
  171 + for (AntenatalExaminationModel a : ant) {
  172 + try {
  173 + if (StringUtils.isNotEmpty(a.getHospitalId())) {
  174 + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId()));
  175 + if (null != og) {
  176 + twinsPatientsResult.setCurrentCh(og.getName());
  177 + break;
  178 + }
  179 + }
  180 + } catch (Exception e) {
  181 + twinsPatientsResult.setCurrentCh("");
  182 + }
  183 + }
  184 + } else {
  185 + for (AntExChuModel a : chu) {
  186 + try {
  187 + if (StringUtils.isNotEmpty(a.getHospitalId())) {
  188 + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId()));
  189 + if (null != og) {
  190 + twinsPatientsResult.setCurrentCh(og.getName());
  191 + break;
  192 + }
  193 + }
  194 + } catch (Exception e) {
  195 + twinsPatientsResult.setCurrentCh("");
  196 + }
  197 + }
  198 + }
  199 +
  200 + twinsPatientsResult.setcTimes(i + ichu);
  201 +
  202 +
  203 + antExQuery.setHospitalId(hospital);
  204 + //本院初诊
  205 + int chi = countAntChu(chu, hospital);
  206 +
  207 + //本院复诊
  208 + int chb = capLocalHospital(hospital, ant);
  209 + twinsPatientsResult.setcHTimes(chi + chb);
  210 + stopWatch.stop();
  211 + String nextCheckTime = "";
  212 + stopWatch.start("query antex list");
  213 +
  214 +
  215 + if (null != patients.getNextCheckTime()) {
  216 + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime());
  217 + }
  218 +
  219 + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) {
  220 + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) {
  221 + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId()));
  222 + if (null != users) {
  223 + twinsPatientsResult.setCheckDoctor(users.getName());
  224 + } else {
  225 + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId());
  226 + }
  227 + } else {
  228 + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId());
  229 + }
  230 + }
  231 +
  232 +
  233 + stopWatch.stop();
  234 + stopWatch.start("query basicconfig");
  235 + //注册地址
  236 + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService));
  237 + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService));
  238 + try {
  239 + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName());
  240 + } catch (Exception e) {
  241 + twinsPatientsResult.setFirstBH("");
  242 + }
  243 +
  244 + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType()));
  245 + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus()));
  246 + //修改获取建档里面的高危等级不用在重新去算
  247 +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true);
  248 +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel()));
  249 + twinsPatientsResult.setcTime(nextCheckTime);
  250 +
  251 +
  252 + //高危因素
  253 + List<String> factor = patients.getRiskFactorId();
  254 +
  255 + if (CollectionUtils.isNotEmpty(factor)) {
  256 + StringBuilder sb = new StringBuilder(56);
  257 + for (String srt : factor) {
  258 + if (StringUtils.isNotEmpty(srt)) {
  259 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt);
  260 + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) {
  261 + if(basicConfig.getName().contains("RH(-)") ||
  262 + basicConfig.getName().contains("Rh血型不合")){
  263 + sb.append(basicConfig.getName()).append(',');
  264 + }
  265 + }
  266 + }
  267 + }
  268 + if (sb.toString().endsWith(",")) {
  269 + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1));
  270 + } else {
  271 + twinsPatientsResult.setrFactor(sb.toString());
  272 + }
  273 +
  274 + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) {
  275 + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor());
  276 + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) {
  277 + twinsPatientsResult.setrFactor(patients.getoRiskFactor());
  278 + }*/
  279 + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) {
  280 + twinsPatientsResult.setrFactor(patients.getoRiskFactor());
  281 + }
  282 + List level = new ArrayList();
  283 + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) {
  284 + try {
  285 + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class);
  286 + for (String str : list) {
  287 + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str);
  288 + if (null != basicConfig) {
  289 + Map map = new HashMap();
  290 + basicConfig.replenRisk(map);
  291 + // String name = basicConfig.getName();
  292 + // if (name.indexOf("预警") > -1) {
  293 + // name = name.replace("预警", "");
  294 + // }
  295 + // map.put("name", name);
  296 + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name));
  297 + level.add(map);
  298 + }
  299 + }
  300 + } catch (Exception e) {
  301 + ExceptionUtils.catchException(e, "patients.getRiskLevelId error.");
  302 + }
  303 +
  304 + twinsPatientsResult.setrLevel(HighScoreResult.filter(level));
  305 + }
  306 + twinsPatientsResult.setCardNo(patients.getCardNo());
  307 + twinsPatientsResult.setPcerteTypeId(patients.getPcerteTypeId());
  308 + stopWatch.stop();
  309 + if (twinsPatientsResult.getrFactor() != null) {
  310 +
  311 + if ("1,".equals(twinsType)) {
  312 + if (twinsPatientsResult.getrFactor().contains("RH(-)")) {
  313 + data.add(twinsPatientsResult);
  314 + }
  315 +
  316 + } else if ("2,".equals(twinsType)) {
  317 + if (twinsPatientsResult.getrFactor().contains("Rh血型不合")) {
  318 + data.add(twinsPatientsResult);
  319 + }
  320 + }else {
  321 + if (twinsPatientsResult.getrFactor().contains("RH(-)")||twinsPatientsResult.getrFactor().contains("Rh血型不合")) {
  322 + data.add(twinsPatientsResult);
  323 + }
  324 + }
  325 + }
  326 + logger.debug(stopWatch.toString());
  327 + }
  328 + return data;
  329 + }
  330 +
  331 + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) {
  332 + if (CollectionUtils.isEmpty(list)) {
  333 + return 0;
  334 + }
  335 + int count = 0;
  336 + for (AntenatalExaminationModel model : list) {
  337 + if (model.getHospitalId().equals(hospitalId)) {
  338 + count++;
  339 + }
  340 + }
  341 + return count;
  342 + }
  343 +
  344 + //统计复查里面的本院检查数
  345 + private int countAntChu(List<AntExChuModel> list, String hospital) {
  346 + int count = 0;
  347 + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) {
  348 + return count;
  349 + }
  350 + for (AntExChuModel model : list) {
  351 + if (hospital.equals(model.getHospitalId())) {
  352 + count++;
  353 + }
  354 + }
  355 + return count;
  356 + }
  357 +
  358 + private void sort(List<AntenatalExaminationModel> list) {
  359 + if (CollectionUtils.isEmpty(list)) {
  360 + return;
  361 + }
  362 + Collections.sort(list, new Comparator<AntenatalExaminationModel>() {
  363 + @Override
  364 + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) {
  365 + if (o1.getCreated().getTime() > o2.getCreated().getTime()) {
  366 + return 1;
  367 + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) {
  368 + return -1;
  369 + }
  370 + return 0;
  371 + }
  372 + });
  373 + }
  374 +}