From ac4de13c79fb3e7fa0072e983ce903bc0209a8a7 Mon Sep 17 00:00:00 2001 From: liquanyu Date: Mon, 23 Oct 2017 13:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E6=A3=80=E8=8A=82=E7=82=B9=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/service/AntenatalExaminationService.java | 134 ++++++++++++++++++++- 1 file changed, 131 insertions(+), 3 deletions(-) diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AntenatalExaminationService.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AntenatalExaminationService.java index 8b6187a..0d74f48 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AntenatalExaminationService.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/AntenatalExaminationService.java @@ -6,11 +6,14 @@ import com.lyms.platform.common.dao.operator.MongoCondition; import com.lyms.platform.common.dao.operator.MongoOper; import com.lyms.platform.common.dao.operator.MongoQuery; import com.lyms.platform.common.enums.YnEnums; +import com.lyms.platform.common.utils.DateUtil; import com.lyms.platform.pojo.AntExChuModel; import com.lyms.platform.pojo.AntExRecordModel; import com.lyms.platform.pojo.AntenatalExaminationModel; +import com.lyms.platform.pojo.Patients; import com.lyms.platform.query.AntExChuQuery; import com.lyms.platform.query.AntExRecordQuery; +import com.lyms.platform.query.PatientsQuery; import com.lyms.platform.query.VisitQuery; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -18,9 +21,7 @@ import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 产前检查服务实现 @@ -36,6 +37,13 @@ public class AntenatalExaminationService { @Autowired private AntExRecordService antExRecordService; + @Autowired + private PatientsService patientsService; + + + @Autowired + private AntExRecordService recordService; + public List findAllByParentId(String parentId) { Assert.notNull(parentId, "findAllByParentId parentId must not be null."); MongoCondition condition = MongoCondition.newInstance("parentId", parentId, MongoOper.IS).and("yn", YnEnums.YES.getId(), MongoOper.IS); @@ -121,11 +129,131 @@ public class AntenatalExaminationService { antExRecordService.addOneRecord(antExRecordModel); } } + + handleCheckPoint(antExRecordModel.getPid()); } } /** + * 产检统计中计算各个产检节点 的是否是节点中的首次节点 + * @param pid + */ + private void handleCheckPoint(String pid) + { + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setPid(pid); + List pats = patientsService.queryPatient1(patientsQuery,"created"); + + Map> temps = new HashMap>(); + + if (CollectionUtils.isNotEmpty(pats)) + { + for(Patients pat : pats) + { + if (pat.getLastMenses() != null) + { + Object obj = temps.get(DateUtil.getyyyy_MM_dd(pat.getLastMenses())); + if (obj != null) + { + List cc = (List)obj; + cc.add(pat); + temps.put(DateUtil.getyyyy_MM_dd(pat.getLastMenses()),cc); + } + else + { + List cc = new ArrayList(); + cc.add(pat); + temps.put(DateUtil.getyyyy_MM_dd(pat.getLastMenses()),cc); + } + } + } + } + + if (!temps.isEmpty()) + { + for(String key : temps.keySet()) + { + List ids = new ArrayList(); + List patientses = temps.get(key); + if (CollectionUtils.isNotEmpty(patientses)) + { + for(Patients patients : patientses) + { + ids.add(patients.getId()); + } + } + + if (CollectionUtils.isNotEmpty(ids)) + { + AntExRecordQuery antExRecordQuery = new AntExRecordQuery(); + antExRecordQuery.setParentIds(ids); + for (int i = 0 ; i < 7 ; i++) + { + if (i == 0) + { + antExRecordQuery.setcDueWeekStart(0); + antExRecordQuery.setcDueWeekEnd((12 + 1) * 7 - 1); + } + else if (i == 1) + { + antExRecordQuery.setcDueWeekStart(13*7); + antExRecordQuery.setcDueWeekEnd((15 + 1) * 7 - 1); + } + else if (i == 2) + { + antExRecordQuery.setcDueWeekStart(16*7); + antExRecordQuery.setcDueWeekEnd((20 + 1) * 7 - 1); + } + else if (i == 3) + { + antExRecordQuery.setcDueWeekStart(21*7); + antExRecordQuery.setcDueWeekEnd((24 + 1) * 7 - 1); + } + else if (i == 4) + { + antExRecordQuery.setcDueWeekStart(25*7); + antExRecordQuery.setcDueWeekEnd((27 + 1) * 7 - 1); + } + else if (i == 5) + { + antExRecordQuery.setcDueWeekStart(28*7); + antExRecordQuery.setcDueWeekEnd((36 + 1) * 7 - 1); + } + else if (i == 6) + { + antExRecordQuery.setcDueWeekStart(37*7); + antExRecordQuery.setcDueWeekEnd((40 + 1) * 7 - 1); + } + + List list = recordService.queryAntExRecords(antExRecordQuery); + if (CollectionUtils.isNotEmpty(list)) + { + for (int j = 0 ; j < list.size() ; j++) + { + AntExRecordModel m = list.get(j); + if (j == (list.size() - 1)) + { + m.setIsFirst(1); + } + else + { + m.setIsFirst(2); + } + recordService.updateOne(m,m.getId()); + } + } + } + } + } + } + } + + + + + /** * 修改一条新生儿访视记录 * * @param babyVisitModel 新生儿访视记录模型 -- 1.8.3.1