Commit ac4de13c79fb3e7fa0072e983ce903bc0209a8a7

Authored by liquanyu
1 parent 68ddcf6b71

产检节点统计

Showing 1 changed file with 131 additions and 3 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AntenatalExaminationService.java View file @ ac4de13
... ... @@ -6,11 +6,14 @@
6 6 import com.lyms.platform.common.dao.operator.MongoOper;
7 7 import com.lyms.platform.common.dao.operator.MongoQuery;
8 8 import com.lyms.platform.common.enums.YnEnums;
  9 +import com.lyms.platform.common.utils.DateUtil;
9 10 import com.lyms.platform.pojo.AntExChuModel;
10 11 import com.lyms.platform.pojo.AntExRecordModel;
11 12 import com.lyms.platform.pojo.AntenatalExaminationModel;
  13 +import com.lyms.platform.pojo.Patients;
12 14 import com.lyms.platform.query.AntExChuQuery;
13 15 import com.lyms.platform.query.AntExRecordQuery;
  16 +import com.lyms.platform.query.PatientsQuery;
14 17 import com.lyms.platform.query.VisitQuery;
15 18 import org.apache.commons.collections.CollectionUtils;
16 19 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -18,9 +21,7 @@
18 21 import org.springframework.stereotype.Service;
19 22 import org.springframework.util.Assert;
20 23  
21   -import java.util.Date;
22   -import java.util.List;
23   -import java.util.Map;
  24 +import java.util.*;
24 25  
25 26 /**
26 27 * 产前检查服务实现
... ... @@ -36,6 +37,13 @@
36 37 @Autowired
37 38 private AntExRecordService antExRecordService;
38 39  
  40 + @Autowired
  41 + private PatientsService patientsService;
  42 +
  43 +
  44 + @Autowired
  45 + private AntExRecordService recordService;
  46 +
39 47 public List<AntenatalExaminationModel> findAllByParentId(String parentId) {
40 48 Assert.notNull(parentId, "findAllByParentId parentId must not be null.");
41 49 MongoCondition condition = MongoCondition.newInstance("parentId", parentId, MongoOper.IS).and("yn", YnEnums.YES.getId(), MongoOper.IS);
42 50  
... ... @@ -121,8 +129,128 @@
121 129 antExRecordService.addOneRecord(antExRecordModel);
122 130 }
123 131 }
  132 +
  133 + handleCheckPoint(antExRecordModel.getPid());
124 134 }
125 135 }
  136 +
  137 +
  138 + /**
  139 + * 产检统计中计算各个产检节点 的是否是节点中的首次节点
  140 + * @param pid
  141 + */
  142 + private void handleCheckPoint(String pid)
  143 + {
  144 + PatientsQuery patientsQuery = new PatientsQuery();
  145 + patientsQuery.setYn(YnEnums.YES.getId());
  146 + patientsQuery.setPid(pid);
  147 + List<Patients> pats = patientsService.queryPatient1(patientsQuery,"created");
  148 +
  149 + Map<String,List<Patients>> temps = new HashMap<String, List<Patients>>();
  150 +
  151 + if (CollectionUtils.isNotEmpty(pats))
  152 + {
  153 + for(Patients pat : pats)
  154 + {
  155 + if (pat.getLastMenses() != null)
  156 + {
  157 + Object obj = temps.get(DateUtil.getyyyy_MM_dd(pat.getLastMenses()));
  158 + if (obj != null)
  159 + {
  160 + List<Patients> cc = (List<Patients>)obj;
  161 + cc.add(pat);
  162 + temps.put(DateUtil.getyyyy_MM_dd(pat.getLastMenses()),cc);
  163 + }
  164 + else
  165 + {
  166 + List<Patients> cc = new ArrayList<Patients>();
  167 + cc.add(pat);
  168 + temps.put(DateUtil.getyyyy_MM_dd(pat.getLastMenses()),cc);
  169 + }
  170 + }
  171 + }
  172 + }
  173 +
  174 + if (!temps.isEmpty())
  175 + {
  176 + for(String key : temps.keySet())
  177 + {
  178 + List<String> ids = new ArrayList<String>();
  179 + List<Patients> patientses = temps.get(key);
  180 + if (CollectionUtils.isNotEmpty(patientses))
  181 + {
  182 + for(Patients patients : patientses)
  183 + {
  184 + ids.add(patients.getId());
  185 + }
  186 + }
  187 +
  188 + if (CollectionUtils.isNotEmpty(ids))
  189 + {
  190 + AntExRecordQuery antExRecordQuery = new AntExRecordQuery();
  191 + antExRecordQuery.setParentIds(ids);
  192 + for (int i = 0 ; i < 7 ; i++)
  193 + {
  194 + if (i == 0)
  195 + {
  196 + antExRecordQuery.setcDueWeekStart(0);
  197 + antExRecordQuery.setcDueWeekEnd((12 + 1) * 7 - 1);
  198 + }
  199 + else if (i == 1)
  200 + {
  201 + antExRecordQuery.setcDueWeekStart(13*7);
  202 + antExRecordQuery.setcDueWeekEnd((15 + 1) * 7 - 1);
  203 + }
  204 + else if (i == 2)
  205 + {
  206 + antExRecordQuery.setcDueWeekStart(16*7);
  207 + antExRecordQuery.setcDueWeekEnd((20 + 1) * 7 - 1);
  208 + }
  209 + else if (i == 3)
  210 + {
  211 + antExRecordQuery.setcDueWeekStart(21*7);
  212 + antExRecordQuery.setcDueWeekEnd((24 + 1) * 7 - 1);
  213 + }
  214 + else if (i == 4)
  215 + {
  216 + antExRecordQuery.setcDueWeekStart(25*7);
  217 + antExRecordQuery.setcDueWeekEnd((27 + 1) * 7 - 1);
  218 + }
  219 + else if (i == 5)
  220 + {
  221 + antExRecordQuery.setcDueWeekStart(28*7);
  222 + antExRecordQuery.setcDueWeekEnd((36 + 1) * 7 - 1);
  223 + }
  224 + else if (i == 6)
  225 + {
  226 + antExRecordQuery.setcDueWeekStart(37*7);
  227 + antExRecordQuery.setcDueWeekEnd((40 + 1) * 7 - 1);
  228 + }
  229 +
  230 + List<AntExRecordModel> list = recordService.queryAntExRecords(antExRecordQuery);
  231 + if (CollectionUtils.isNotEmpty(list))
  232 + {
  233 + for (int j = 0 ; j < list.size() ; j++)
  234 + {
  235 + AntExRecordModel m = list.get(j);
  236 + if (j == (list.size() - 1))
  237 + {
  238 + m.setIsFirst(1);
  239 + }
  240 + else
  241 + {
  242 + m.setIsFirst(2);
  243 + }
  244 + recordService.updateOne(m,m.getId());
  245 + }
  246 + }
  247 + }
  248 + }
  249 + }
  250 + }
  251 + }
  252 +
  253 +
126 254  
127 255  
128 256 /**