Commit 1aef0044e78a49a62af1f325f39dfb47d8be5c74

Authored by jiangjiazhi

Merge remote-tracking branch 'origin/master'

Showing 4 changed files

platform-data-api/src/main/java/com/lyms/platform/data/pojo/HighScoreResult.java View file @ 1aef004
  1 +package com.lyms.platform.data.pojo;
  2 +
  3 +import com.lyms.platform.common.utils.StringUtils;
  4 +
  5 +import java.util.ArrayList;
  6 +import java.util.Collections;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * Created by Administrator on 2016/8/2 0002.
  11 + */
  12 +public class HighScoreResult {
  13 +
  14 + //高危因素
  15 + private List highRisk = new ArrayList();
  16 + //风险等级颜色
  17 + private List level = new ArrayList();
  18 + //高危评分
  19 + private Integer score = 0;
  20 +
  21 + public List getHighRisk() {
  22 + return highRisk;
  23 + }
  24 +
  25 + public List getLevel() {
  26 + return level;
  27 + }
  28 +
  29 + public void setLevel(List level) {
  30 + this.level = level;
  31 + }
  32 +
  33 + public void setHighRisk(List highRisk) {
  34 + this.highRisk = highRisk;
  35 + }
  36 +
  37 + public Integer getScore() {
  38 + if (null == score) {
  39 + return 0;
  40 + }
  41 + return score;
  42 + }
  43 +
  44 +
  45 + public String getScoreStr(){
  46 + if(null==score || 0==score){
  47 + return "";
  48 + }
  49 + return score+"";
  50 + }
  51 +
  52 + public List<String> getLevelId() {
  53 + if (null == level) {
  54 + return Collections.emptyList();
  55 + }
  56 + List<String> idList = new ArrayList<>();
  57 + for (int i1 = 0; i1 < level.size(); i1++) {
  58 + java.util.Map<String, String> map = (java.util.Map<String, String>) level.get(i1);
  59 + String name = map.get("id");
  60 + if (StringUtils.isNotEmpty(name)) {
  61 + idList.add(name);
  62 + }
  63 + }
  64 + return idList;
  65 + }
  66 +
  67 + public List<String> getHighId() {
  68 + if (null == highRisk) {
  69 + return Collections.emptyList();
  70 + }
  71 + List<String> idList = new ArrayList<>();
  72 + for (int i1 = 0; i1 < highRisk.size(); i1++) {
  73 + java.util.Map<String, String> map = (java.util.Map<String, String>) highRisk.get(i1);
  74 + String id = map.get("id");
  75 + if (StringUtils.isNotEmpty(id)) {
  76 + idList.add(id);
  77 + }
  78 + }
  79 + return idList;
  80 + }
  81 +
  82 + public void setScore(Integer score) {
  83 + this.score = score;
  84 + }
  85 +
  86 + public String getLevelStr() {
  87 + StringBuilder stringBuilder = new StringBuilder();
  88 + if (null == level) {
  89 + return "";
  90 + }
  91 + for (int i1 = 0; i1 < level.size(); i1++) {
  92 + java.util.Map<String, String> map = (java.util.Map<String, String>) level.get(i1);
  93 + String name = map.get("name");
  94 + if (stringBuilder.indexOf(name) == -1) {
  95 + stringBuilder.append(map.get("name")).append(", ");
  96 + }
  97 + }
  98 + if (stringBuilder.length() >= 2) {
  99 + stringBuilder.setLength(stringBuilder.length() - 2);
  100 + }
  101 + return stringBuilder.toString();
  102 + }
  103 +
  104 + public String gethighRiskStr() {
  105 + StringBuilder stringBuilder = new StringBuilder();
  106 + if (null == highRisk) {
  107 + return "";
  108 + }
  109 + for (int i1 = 0; i1 < highRisk.size(); i1++) {
  110 + java.util.Map<String, String> map = (java.util.Map<String, String>) highRisk.get(i1);
  111 + stringBuilder.append(map.get("name")).append(", ");
  112 + }
  113 + if (stringBuilder.length() >= 2) {
  114 + stringBuilder.setLength(stringBuilder.length() - 2);
  115 + }
  116 + return stringBuilder.toString();
  117 + }
  118 +}
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java View file @ 1aef004
... ... @@ -6,6 +6,7 @@
6 6 import com.lyms.platform.common.utils.JsonUtil;
7 7 import com.lyms.platform.common.utils.Lunar;
8 8 import com.lyms.platform.common.utils.StringUtils;
  9 +import com.lyms.platform.data.pojo.HighScoreResult;
9 10 import com.lyms.platform.data.pojo.MessageContent;
10 11 import com.lyms.platform.data.pojo.MessageListRequest;
11 12 import com.lyms.platform.data.pojo.MessageRequest;
12 13  
... ... @@ -21,7 +22,9 @@
21 22 import com.lyms.platform.pojo.*;
22 23 import com.lyms.platform.query.*;
23 24 import org.apache.commons.collections.CollectionUtils;
  25 +import org.apache.commons.lang.math.NumberUtils;
24 26 import org.springframework.beans.factory.annotation.Autowired;
  27 +import org.springframework.data.domain.Sort;
25 28 import org.springframework.stereotype.Service;
26 29  
27 30 import java.util.*;
28 31  
... ... @@ -52,9 +55,8 @@
52 55 private AntenatalExaminationService antenatalExaminationService;
53 56  
54 57 @Autowired
55   - private BasicConfigService basicConfigService;
  58 + private PatientsService patientsService;
56 59  
57   -
58 60 @Autowired
59 61 private BabyBookbuildingService babyBookbuildingService;
60 62  
61 63  
... ... @@ -63,7 +65,15 @@
63 65 @Autowired
64 66 private OrganizationService organizationService;
65 67  
  68 + @Autowired
  69 + private MatDeliverService matDeliverService;
  70 + @Autowired
  71 + private StopPregnancyService stopPregnancyService;
66 72  
  73 + @Autowired
  74 + private BasicConfigService basicConfigService;
  75 +
  76 +
67 77 /**
68 78 * 生成孕妇ams指导短信
69 79 */
... ... @@ -88,6 +98,20 @@
88 98 {
89 99 continue;
90 100 }
  101 +
  102 + //每周几发送的指导短信
  103 + String timeStr = config.getGuideTime();
  104 + if (StringUtils.isEmpty(timeStr))
  105 + {
  106 + continue;
  107 + }
  108 +
  109 + List<String> guideTimes = JsonUtil.toList(timeStr, String.class);
  110 + if (guideTimes == null || guideTimes.size() != 2)
  111 + {
  112 + continue;
  113 + }
  114 +
91 115 //判断医院是否运行
92 116 if (!isRunning(hospitalId))
93 117 {
94 118  
95 119  
... ... @@ -117,10 +141,14 @@
117 141  
118 142 PatientsQuery patientsQuery = new PatientsQuery();
119 143 patientsQuery.setYn(YnEnums.YES.getId());
  144 + patientsQuery.setHospitalId(hospitalId);
  145 +
120 146 //1孕妇 3 产妇
121 147 patientsQuery.setType(1);
  148 + //分娩状态
  149 + patientsQuery.setDueStatus(0);
122 150  
123   - //末次月经必须大于当前时间减去42周视为分娩孕妇
  151 + //末次月经必须大于当前时间减去42周视为分娩孕妇
124 152 Date lastMensesMax = DateUtil.getNewDate(-42, "周", 1);
125 153 patientsQuery.setLastMensesStart(lastMensesMax);
126 154 //健康指导短信 只能是类型为 增值服务 开通状态 才发送
127 155  
... ... @@ -152,18 +180,7 @@
152 180 messagePrefix = res == "" ? messagePrefix : res;
153 181 }
154 182  
155   - //每周几发送的指导实践
156   - String timeStr = config.getGuideTime();
157   - if (StringUtils.isEmpty(timeStr))
158   - {
159   - continue;
160   - }
161 183  
162   - List<String> guideTimes = JsonUtil.toList(timeStr, String.class);
163   - if (guideTimes == null || guideTimes.size() != 2)
164   - {
165   - continue;
166   - }
167 184 int weekNum = 0;
168 185 for (String guide : guideTimes)
169 186 {
... ... @@ -179,7 +196,7 @@
179 196 * 高危短信
180 197 */
181 198 //获取最后一次高危因素
182   - List risks = findLastRisk(pat.getId());
  199 + List risks = findLastRisk(pat.getPid());
183 200 if (CollectionUtils.isNotEmpty(risks))
184 201 {
185 202 for (Object obj : risks)
... ... @@ -2094,7 +2111,7 @@
2094 2111 if (StringUtils.isNotEmpty(repalceStr))
2095 2112 {
2096 2113 String date = DateUtil.getyyyy_MM_dd(checkDate);
2097   - return repalceStr.replace("{{姓名}}",name).replace("{{预约检查时间}}",date);
  2114 + return repalceStr.replace("{{姓名}}",name).replace("{{预约检查时间}}", date);
2098 2115 }
2099 2116 return repalceStr;
2100 2117 }
... ... @@ -2125,7 +2142,7 @@
2125 2142 //前缀类型 0医院前缀 1科室前缀
2126 2143 if (config.getPrefixType() != null && config.getPrefixType() == 1)
2127 2144 {
2128   - String res = getDeptPrefix(doctorId,config.getDeptPrefix());
  2145 + String res = getDeptPrefix(doctorId, config.getDeptPrefix());
2129 2146 messagePrefix = res == "" ? messagePrefix : res;
2130 2147 }
2131 2148 return messagePrefix;
2132 2149  
2133 2150  
2134 2151  
2135 2152  
2136 2153  
2137 2154  
2138 2155  
2139 2156  
2140 2157  
2141 2158  
... ... @@ -2275,47 +2292,155 @@
2275 2292  
2276 2293 /**
2277 2294 * 获取最后一次高危产检的高危信息
2278   - *
  2295 + * <p>
2279 2296 * 先取复诊最后一条,在取初诊
2280 2297 *
2281 2298 * @return
2282 2299 */
2283   - public List findLastRisk(String parentId) {
2284   - List<AntenatalExaminationModel> list = antenatalExaminationService.findAllByParentId(parentId);
2285   - AntenatalExaminationModel model = null;
2286   - if (CollectionUtils.isNotEmpty(list)) {
2287   - model = list.get(0);
  2300 + public List findLastRisk(String pid) {
  2301 + MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
  2302 + matDeliverQuery.setPid(pid);
  2303 + matDeliverQuery.setYn(YnEnums.YES.getId());
  2304 + List<SortIn> listDate = new ArrayList<>();
  2305 + //分娩记录
  2306 + List<MaternalDeliverModel> modelList = matDeliverService.query(matDeliverQuery);
  2307 + if (CollectionUtils.isNotEmpty(modelList)) {
  2308 + for (MaternalDeliverModel model : modelList) {
  2309 + listDate.add(new SortIn(model));
  2310 + }
2288 2311 }
2289   - try {
2290   - if(null!=model){
2291   - List list1 = JsonUtil.toList(model.getRiskFactor(), List.class);
2292   - return queryRisk(list1);
  2312 +
  2313 + //终止妊娠记录
  2314 + StopPregQuery query = new StopPregQuery();
  2315 + query.setYn(YnEnums.YES.getId());
  2316 + query.setPid(pid);
  2317 + List<StopPregModel> stopPregs = stopPregnancyService.queryStopPreg(query);
  2318 + if (CollectionUtils.isNotEmpty(stopPregs)) {
  2319 + for (StopPregModel stopPregModel : stopPregs) {
  2320 + listDate.add(new SortIn(stopPregModel));
2293 2321 }
2294   - } catch (Exception e) {
2295 2322 }
2296   - AntExChuQuery antExChuQuery = new AntExChuQuery();
2297   - antExChuQuery.setParentId(parentId);
2298   - antExChuQuery.setYn(YnEnums.YES.getId());
2299   - List<AntExChuModel> list1 = antenatalExaminationService.queryAntExChu(antExChuQuery);
2300   - AntExChuModel antExChuModel = null;
2301   - if (CollectionUtils.isNotEmpty(list1)) {
2302   - antExChuModel = list1.get(0);
  2323 + PatientsQuery patientsQuery = new PatientsQuery();
  2324 + patientsQuery.setPid(pid);
  2325 + patientsQuery.setType(3);
  2326 + patientsQuery.setYn(YnEnums.YES.getId());
  2327 + List<Patients> patientses = patientsService.queryPatient(patientsQuery);
  2328 + if (CollectionUtils.isNotEmpty(patientses)) {
  2329 + for (Patients patients : patientses) {
  2330 + listDate.add(new SortIn(patients, 1));
  2331 + }
2303 2332 }
  2333 + //排序集合
  2334 + sortList(listDate);
  2335 +
  2336 +
  2337 + PatientsQuery patientsQuery1 = new PatientsQuery();
  2338 + patientsQuery1.setPid(pid);
  2339 + patientsQuery1.setType(1);
  2340 + List<Patients> patientses1 = patientsService.findLatelyCreated(patientsQuery1.convertToQuery().addOrder(Sort.Direction.ASC, "created"));
  2341 +
  2342 + Date min = null;
  2343 + if (CollectionUtils.isNotEmpty(patientses1)) {
  2344 + min = patientses1.get(0).getBookbuildingDate();
  2345 + }
  2346 +
  2347 + Date max = null;
  2348 + if (!listDate.isEmpty()) {
  2349 + max = listDate.get(0).getDate();
  2350 + }
  2351 +
  2352 + HighScoreResult highScoreResult = getPatLastRiskByDate(pid,min, max);
  2353 + return highScoreResult.getHighRisk();
  2354 + }
  2355 +
  2356 + private void sortList(List listDate) {
  2357 + //按照数据排序
  2358 + Collections.sort(listDate, new Comparator<SortIn>() {
  2359 + @Override
  2360 + public int compare(SortIn o1, SortIn o2) {
  2361 + if (o1.getDate().after(o2.getDate())) {
  2362 + return -1;
  2363 + }
  2364 + if (o1.getDate().before(o2.getDate())) {
  2365 + return 1;
  2366 + }
  2367 + return 0;
  2368 + }
  2369 + });
  2370 + }
  2371 +
  2372 + /**
  2373 + * 查询当前产程孕妇高危因素
  2374 + *
  2375 + * @param pid
  2376 + * @param date
  2377 + * @return
  2378 + */
  2379 + public HighScoreResult getPatLastRiskByDate(String pid, Date min,Date date) {
  2380 + AntExQuery antExQuery = new AntExQuery();
  2381 + antExQuery.setPid(pid);
  2382 + antExQuery.setYn(YnEnums.YES.getId());
  2383 + if (min != null) {
  2384 + antExQuery.setStart(min);
  2385 + }else if(null!=date){
  2386 + antExQuery.setEnd(date);
  2387 + }
  2388 + List<AntenatalExaminationModel> list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "modified"));
  2389 + HighScoreResult highScoreResult = new HighScoreResult();
  2390 + boolean next = true;
  2391 + if (CollectionUtils.isNotEmpty(list)) {
  2392 + for (AntenatalExaminationModel model : list) {
  2393 + if (!next) {
  2394 + break;
  2395 + }
  2396 + //复诊
  2397 + if (null != model && org.apache.commons.lang.StringUtils.isNotEmpty(model.getRiskFactor()) && !"[]".equals(model.getRiskFactor())) {
  2398 + List list1 = JsonUtil.toList(model.getRiskFactor(), List.class);
  2399 + highScoreResult = queryRisk(list1);
  2400 + next = false;
  2401 + }
  2402 + }
  2403 + }
  2404 +
2304 2405 try {
2305   - if(null!=antExChuModel){
2306   - List list2 = JsonUtil.toList(antExChuModel.getHighrisk(), List.class);
2307   - return queryRisk(list2);
  2406 +
  2407 + if (next) {
  2408 + //初诊
  2409 + AntExChuQuery antExChuQuery = new AntExChuQuery();
  2410 + antExChuQuery.setPid(pid);
  2411 + if (min != null) {
  2412 + antExChuQuery.setStart(min);
  2413 + } else if (date != null) {
  2414 + antExChuQuery.setEnd(date);
  2415 + }
  2416 + antExChuQuery.setYn(YnEnums.YES.getId());
  2417 + List<AntExChuModel> list1 = antenatalExaminationService.queryAntExChu(antExChuQuery);
  2418 + if (CollectionUtils.isNotEmpty(list1)) {
  2419 + for (AntExChuModel antExChuModel : list1) {
  2420 + if (!next) {
  2421 + break;
  2422 + }
  2423 + if (null != antExChuModel && org.apache.commons.lang.StringUtils.isNotEmpty(antExChuModel.getHighrisk()) && !"[]".equals(antExChuModel.getHighrisk())) {
  2424 + List list2 = JsonUtil.toList(antExChuModel.getHighrisk(), List.class);
  2425 + highScoreResult = queryRisk(list2);
  2426 + next = false;
  2427 + }
  2428 + }
  2429 + }
  2430 +
2308 2431 }
  2432 +
2309 2433 } catch (Exception e) {
2310 2434 }
2311   - return Collections.emptyList();
  2435 + return highScoreResult;
2312 2436 }
2313 2437  
2314   -
2315   - public List queryRisk(List<String> id) {
  2438 + public HighScoreResult queryRisk(List<String> id) {
  2439 + HighScoreResult highScoreResult = new HighScoreResult();
2316 2440 BasicConfigQuery
2317 2441 basicConfigQuery = new BasicConfigQuery();
2318 2442 List data = new ArrayList();
  2443 + Integer score = null;
2319 2444 if (CollectionUtils.isNotEmpty(id)) {
2320 2445 for (String i : id) {
2321 2446 basicConfigQuery.setId(i);
2322 2447  
... ... @@ -2330,9 +2455,67 @@
2330 2455 }
2331 2456 }
2332 2457 }
2333   - return data;
  2458 + highScoreResult.setHighRisk(data);
  2459 + return highScoreResult;
2334 2460 }
2335 2461  
  2462 +
  2463 + public class SortIn {
  2464 +
  2465 + public SortIn(Patients patients) {
  2466 + this.id = patients.getId();
  2467 + this.date = patients.getBookbuildingDate();
  2468 + this.type = 2;
  2469 + }
  2470 +
  2471 + public SortIn(Patients patients, int i) {
  2472 + this.id = patients.getId();
  2473 + this.date = patients.getFmDate();
  2474 + this.type = 2;
  2475 + }
  2476 +
  2477 + public SortIn(StopPregModel stopPregModel) {
  2478 + this.id = stopPregModel.getId();
  2479 + this.date = stopPregModel.getStopDate();
  2480 + this.type = 1;
  2481 + }
  2482 +
  2483 + public SortIn(MaternalDeliverModel maternalDeliverModel) {
  2484 + this.id = maternalDeliverModel.getId();
  2485 + this.date = DateUtil.parseYMD(maternalDeliverModel.getDueDate());
  2486 + this.type = 3;
  2487 + }
  2488 +
  2489 +
  2490 + private String id;
  2491 + //type为1 表示终止妊娠数据 2 表示自然分娩数据
  2492 + private int type;
  2493 + private Date date;
  2494 +
  2495 + public Date getDate() {
  2496 + return date;
  2497 + }
  2498 +
  2499 + public int getType() {
  2500 + return type;
  2501 + }
  2502 +
  2503 + public void setType(int type) {
  2504 + this.type = type;
  2505 + }
  2506 +
  2507 + public void setDate(Date date) {
  2508 + this.date = date;
  2509 + }
  2510 +
  2511 + public String getId() {
  2512 + return id;
  2513 + }
  2514 +
  2515 + public void setId(String id) {
  2516 + this.id = id;
  2517 + }
  2518 + }
2336 2519  
2337 2520 @Override
2338 2521 public void getBirthPatients() {
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBookbuildingController.java View file @ 1aef004
... ... @@ -100,14 +100,14 @@
100 100 */
101 101 @RequestMapping(value = "/queryBabyBuildRecord", method = RequestMethod.GET)
102 102 @ResponseBody
103   - @TokenRequired
  103 +// @TokenRequired
104 104 public BaseObjectResponse queryBabyBuildRecord(HttpServletRequest request,@RequestParam(required = false)String cardNo,@RequestParam(required = false)String vcCardNo,@RequestParam(required = false)String hospitalId){
105 105 BookbuildingQueryRequest param = new BookbuildingQueryRequest();
106 106 param.setCardNo(cardNo);
107 107 param.setVcCardNo(vcCardNo);
108 108 param.setHospitalId(hospitalId);
109   - LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
110   - return babyBookbuildingFacade.queryBabyBuildRecord(param,loginState.getId());
  109 +// LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  110 + return babyBookbuildingFacade.queryBabyBuildRecord(param,null);
111 111 }
112 112  
113 113  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java View file @ 1aef004
... ... @@ -441,6 +441,7 @@
441 441 }
442 442 model.setCreated(new Date());
443 443 model.setModified(new Date());
  444 + model.setBuildType(1);
444 445 model = babyBookbuildingService.addBabyBookbuilding(model);
445 446  
446 447 if (model == null || model.getId() == null) {
... ... @@ -714,6 +715,7 @@
714 715  
715 716  
716 717  
  718 +
717 719 return bm;
718 720 }
719 721  
... ... @@ -731,6 +733,27 @@
731 733 if (CollectionUtils.isNotEmpty(checkModels))
732 734 {
733 735 return new BaseResponse().setErrorcode(ErrorCodeConstants.DONT_DELETE).setErrormsg("存在儿童检查记录,不能删除建档");
  736 + }
  737 +
  738 + BabyModelQuery babyQuery = new BabyModelQuery();
  739 + babyQuery.setId(id);
  740 + babyQuery.setYn(YnEnums.YES.getId());
  741 + List<BabyModel> models = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
  742 + if (CollectionUtils.isNotEmpty(models))
  743 + {
  744 + babyQuery.setId(null);
  745 + babyQuery.setPid(models.get(0).getPid());
  746 + List<BabyModel> allModels = babyBookbuildingService.queryBabyBuildByCond(babyQuery);
  747 + if (CollectionUtils.isNotEmpty(allModels))
  748 + {
  749 + if (allModels.get(0) != null && allModels.get(0).getId().equals(id) && allModels.size() == 0)
  750 + {
  751 + PersonModel personModel = new PersonModel();
  752 + personModel.setYn(YnEnums.NO.getId());
  753 + personService.updatePerson(personModel,allModels.get(0).getPid());
  754 + }
  755 + }
  756 +
734 757 }
735 758  
736 759 babyBookbuildingService.deleteBabyById(id);