From 14737cc1dbd308c8d2356d969dd0a78e0b068815 Mon Sep 17 00:00:00 2001 From: jiangjiazhi Date: Tue, 23 Aug 2016 09:56:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E7=97=85=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lyms/platform/query/PatientsQuery.java | 35 +++ .../com/lyms/platform/query/StopPregQuery.java | 13 +- .../controller/AntenatalExaminationController.java | 2 +- .../web/facade/AntenatalExaminationFacade.java | 299 ++++++++++++++++++++- 4 files changed, 335 insertions(+), 14 deletions(-) diff --git a/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java index 5e1e1ab..ef3130b 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java @@ -71,6 +71,9 @@ public class PatientsQuery extends BaseQuery implements IConvertToNativeQuery { //创建时间 private Date created; + private Date bookbuildingDateStart; + private Date bookbuildingDateEnd; + private String pid; public Date getCreated() { @@ -218,6 +221,22 @@ public class PatientsQuery extends BaseQuery implements IConvertToNativeQuery { this.lastMensesEnd = lastMensesEnd; } + public Date getBookbuildingDateEnd() { + return bookbuildingDateEnd; + } + + public void setBookbuildingDateEnd(Date bookbuildingDateEnd) { + this.bookbuildingDateEnd = bookbuildingDateEnd; + } + + public Date getBookbuildingDateStart() { + return bookbuildingDateStart; + } + + public void setBookbuildingDateStart(Date bookbuildingDateStart) { + this.bookbuildingDateStart = bookbuildingDateStart; + } + public Date getLastMensesStart() { return lastMensesStart; } @@ -566,6 +585,22 @@ public class PatientsQuery extends BaseQuery implements IConvertToNativeQuery { } isAddStart = Boolean.TRUE; } + + + if (null != bookbuildingDateStart) { + c = Criteria.where("bookbuildingDate").gte(bookbuildingDateStart); + isAddStart = Boolean.TRUE; + } + if (null != bookbuildingDateEnd) { + if (isAddStart) { + c = c.lte(bookbuildingDateEnd); + } else { + c = Criteria.where("bookbuildingDate").lte(bookbuildingDateEnd); + } + isAddStart = Boolean.TRUE; + } + + if (isAddStart) { return new MongoCondition(c.andOperator(condition.getCriteria())).toMongoQuery(); } diff --git a/platform-dal/src/main/java/com/lyms/platform/query/StopPregQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/StopPregQuery.java index 71d3cae..7ba6aa2 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/StopPregQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/StopPregQuery.java @@ -33,6 +33,7 @@ public class StopPregQuery extends BaseQuery implements IConvertToNativeQuery { private String inPerson; private Integer yn; + private String pid; @Override public MongoQuery convertToQuery() { @@ -47,7 +48,9 @@ public class StopPregQuery extends BaseQuery implements IConvertToNativeQuery { if (-1 != yn) { condition = condition.and("yn", yn, MongoOper.IS); } - + if (null!= pid) { + condition = condition.and("pid", pid, MongoOper.IS); + } return condition.toMongoQuery(); } @@ -106,4 +109,12 @@ public class StopPregQuery extends BaseQuery implements IConvertToNativeQuery { public void setInPerson(String inPerson) { this.inPerson = inPerson; } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AntenatalExaminationController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AntenatalExaminationController.java index 6e0ad1a..be3e3d4 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AntenatalExaminationController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AntenatalExaminationController.java @@ -116,6 +116,6 @@ public class AntenatalExaminationController extends BaseController { @ResponseBody @TokenRequired public BaseResponse findAntExList(@Valid AntExListQueryRequest exListQueryRequest) { - return antenatalExaminationFacade.findAntExList(exListQueryRequest); + return antenatalExaminationFacade.findAntExListTwo(exListQueryRequest); } } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java index bb312d8..075e4f2 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java @@ -3,6 +3,7 @@ package com.lyms.platform.operate.web.facade; import com.lyms.platform.biz.service.*; import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.enums.*; +import com.lyms.platform.common.result.BaseListResponse; import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.result.BaseResponse; import com.lyms.platform.common.utils.Assert; @@ -374,6 +375,280 @@ public class AntenatalExaminationFacade { } /** + * 电子病历方法 + * + * @param exListQueryRequest + * @return + */ + public BaseResponse findAntExListTwo(AntExListQueryRequest exListQueryRequest) { + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setCardNo(exListQueryRequest.getCardNo()); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setPhone(exListQueryRequest.getPhone()); + patientsQuery.setPid(exListQueryRequest.getPid()); + //获取所有的建档记录 + List list = patientsService.queryPatient(patientsQuery); + + Map map = new HashMap(); + + List sortList = new ArrayList(); + + List listDate = new ArrayList(); + int index = 0; + if (CollectionUtils.isNotEmpty(list)) { + + MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); + matDeliverQuery.setPid(list.get(0).getPid()); + matDeliverQuery.setYn(YnEnums.YES.getId()); + //分娩记录 + List modelList = matDeliverService.query(matDeliverQuery); + for (MaternalDeliverModel model : modelList) { + listDate.add(new SortIn(model)); + map.put(model.getId(), model); + } + //终止妊娠记录 + StopPregQuery query = new StopPregQuery(); + query.setYn(YnEnums.YES.getId()); + query.setPid(list.get(0).getPid()); + List stopPregs = stopPregnancyService.queryStopPreg(query); + for (StopPregModel stopPregModel : stopPregs) { + listDate.add(new SortIn(stopPregModel)); + map.put(stopPregModel.getId(), stopPregModel); + } + //排序集合 + sortList(listDate); + + //TODO 需要过滤掉建档就分娩的情况 + Date dueDate = new Date(); + if (CollectionUtils.isNotEmpty(listDate)) { + String pid=""; + for (int i = 0; i < listDate.size(); i++) { + dueDate = listDate.get(i).getDate(); + List listData = new ArrayList(); + Organization organization = null; + PatientsQuery patientsQuery1 = new PatientsQuery(); + patientsQuery1.setBookbuildingDateEnd(new Date(listDate.get(i).getDate().getTime()+i)); + if (listDate.size() > i + 1) { + patientsQuery1.setBookbuildingDateStart(listDate.get(i + 1).getDate()); + }else{ + patientsQuery1.setBookbuildingDateStart(new Date()); + } + pid=list.get(0).getPid(); + patientsQuery1.setPid(pid); + List patientses = patientsService.queryPatient1(patientsQuery1); + Iterator iterator=patientses.iterator(); + while(iterator.hasNext()){ + Patients patients= iterator.next(); + Date date = DateUtil.addWeek(patients.getLastMenses(),42); + Date currentDate = DateUtil.formatDate(patients.getBookbuildingDate()); + if (date.getTime() <= currentDate.getTime()) + { + //建档记录 + if (null != patients.getHospitalId()) { + organization = organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())); + } + pid = patients.getPid(); + listData.add(new AntData(patients, null != organization ? organization.getName() : "")); + iterator.remove(); + + + PostReviewQuery postReviewQuery = new PostReviewQuery(); + if (list.size() - 1 > i) { + postReviewQuery.setStart(dueDate); + //下次建档记录前都是产后复查,如果没有下个产程的数据就直接显示 + postReviewQuery.setEnd(patientses.get(0).getBookbuildingDate()); + } + postReviewQuery.setPid(pid); +// Object obj = map.get(listDate.get(i).getId()); + /* if (obj instanceof MaternalDeliverModel) { + listData.add(new AntData((MaternalDeliverModel) obj, patientses.get(0).getLastMenses(), null != organization ? organization.getName() : "")); + } else if (obj instanceof StopPregModel) { + listData.add(new AntData(stopPregs.get(0), patientses.get(0).getLastMenses(), null != organization ? organization.getName() : "")); + }*/ + + //产后复查记录 + List reviewModels = postReviewService.findWithList(postReviewQuery); + if (CollectionUtils.isNotEmpty(reviewModels)) { + for (PostReviewModel postReviewModel : reviewModels) { + if (null != postReviewModel.getHospitalId()) { + organization = organizationService.getOrganization(Integer.valueOf(postReviewModel.getHospitalId())); + } + listData.add(new AntData(postReviewModel, null != organization ? organization.getName() : "", patientses.get(0).getFmDate())); + } + } + sortList.add(listData); + listData=new ArrayList(); + } + } + if(CollectionUtils.isNotEmpty(patientses)){ + buildPatientList(dueDate,patientses,listData); + + PostReviewQuery postReviewQuery = new PostReviewQuery(); + if (list.size() - 1 > i) { + postReviewQuery.setStart(dueDate); + //下次建档记录前都是产后复查,如果没有下个产程的数据就直接显示 + postReviewQuery.setEnd(patientses.get(0).getBookbuildingDate()); + } + postReviewQuery.setPid(pid); + Object obj = map.get(listDate.get(i).getId()); + if (obj instanceof MaternalDeliverModel) { + listData.add(new AntData((MaternalDeliverModel) obj, patientses.get(0).getLastMenses(), null != organization ? organization.getName() : "")); + } else if (obj instanceof StopPregModel) { + listData.add(new AntData(stopPregs.get(0), patientses.get(0).getLastMenses(), null != organization ? organization.getName() : "")); + } + + //产后复查记录 + List reviewModels = postReviewService.findWithList(postReviewQuery); + if (CollectionUtils.isNotEmpty(reviewModels)) { + for (PostReviewModel postReviewModel : reviewModels) { + if (null != postReviewModel.getHospitalId()) { + organization = organizationService.getOrganization(Integer.valueOf(postReviewModel.getHospitalId())); + } + listData.add(new AntData(postReviewModel, null != organization ? organization.getName() : "", patientses.get(0).getFmDate())); + } + } + } + sortList.add(listData); + } + PatientsQuery patientsQuery1=new PatientsQuery(); + patientsQuery1.setYn(YnEnums.YES.getId()); + patientsQuery1.setPid(pid); + patientsQuery1.setBookbuildingDateStart(new Date(listDate.get(0).getDate().getTime()+1000)); + patientsQuery1.setType(1); + List patientsList = patientsService.queryPatient(patientsQuery1); + List list1=new ArrayList(); + sortList.add(buildPatientList(dueDate, patientsList, list1)); + }else{ + List list1=new ArrayList(); + sortList.add(buildPatientList(dueDate, list,list1)); + } + } + return new BaseListResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(sortList); + } + + + + + private List buildPatientList(Date dueDate, List patientses,List listData) { + + Organization organization = null; + String pid = ""; + for (Patients patients : patientses) { + //建档记录 + if (null != patients.getHospitalId()) { + organization = organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())); + } + pid = patients.getPid(); + listData.add(new AntData(patients, null != organization ? organization.getName() : "")); + } + + + if (null != dueDate) { + //初诊记录 + AntExChuQuery antExChuQuery = new AntExChuQuery(); + antExChuQuery.setYn(YnEnums.YES.getId()); + antExChuQuery.setStart(patientses.get(0).getBookbuildingDate()); + antExChuQuery.setEnd(new Date(dueDate.getTime() + 86398000)); + antExChuQuery.setPid(pid); + + List antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery); + if (CollectionUtils.isNotEmpty(antExChuModels)) { + for (AntExChuModel an : antExChuModels) { + if (null != an.getHospitalId()) { + organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId())); + } + listData.add(new AntData(an, null != organization ? organization.getName() : "", patientses.get(0).getLastMenses())); + } + } + + //复诊记录 + AntExQuery antExQuery = new AntExQuery(); + antExQuery.setYn(YnEnums.YES.getId()); + antExQuery.setPid(pid); + antExQuery.setStart(patientses.get(0).getBookbuildingDate()); + antExQuery.setEnd(new Date(dueDate.getTime() + 86398000)); + List list1 = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery()); + if (CollectionUtils.isNotEmpty(list1)) { + for (AntenatalExaminationModel an : list1) { + if (null != an.getHospitalId()) { + organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId())); + } + listData.add(new AntData(an, null != organization ? organization.getName() : "", patientses.get(0).getLastMenses())); + } + } + } + return listData; + } + + private void sortList(List listDate) { + //按照数据排序 + Collections.sort(listDate, new Comparator() { + @Override + public int compare(SortIn o1, SortIn o2) { + if (o1.getDate().after(o2.getDate())) { + return -1; + } + if (o1.getDate().before(o2.getDate())) { + return 1; + } + return 0; + } + }); + } + + + public class SortIn { + + public SortIn(Patients patients) { + this.id = patients.getId(); + this.date = patients.getBookbuildingDate(); + this.type = 2; + } + + public SortIn(StopPregModel stopPregModel) { + this.id = stopPregModel.getId(); + this.date = stopPregModel.getStopDate(); + this.type = 1; + } + + public SortIn(MaternalDeliverModel maternalDeliverModel) { + this.id = maternalDeliverModel.getId(); + this.date = DateUtil.parseYMD(maternalDeliverModel.getDueDate()); + this.type = 3; + } + + + private String id; + //type为1 表示终止妊娠数据 2 表示自然分娩数据 + private int type; + private Date date; + + public Date getDate() { + return date; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + } + + /** * 查询产妇所有产检的数据 * * @param exListQueryRequest @@ -740,12 +1015,12 @@ public class AntenatalExaminationFacade { data = patients.getLastMenses(); } - String doctorId = examinationModel.getCheckDoctor(); - Users users= usersService.getUsers(Integer.valueOf(doctorId)); - Map map1 =new HashMap<>(); - if(null!=users){ - map1.put("id",users.getId()+""); - map1.put("name",users.getName()); + String doctorId = examinationModel.getCheckDoctor(); + Users users = usersService.getUsers(Integer.valueOf(doctorId)); + Map map1 = new HashMap<>(); + if (null != users) { + map1.put("id", users.getId() + ""); + map1.put("name", users.getName()); } antenatalExaminationResult.setCheckDoctor(map1); antenatalExaminationResult.setIsSieve(cap(data, examinationModel.getParentId())); @@ -778,12 +1053,12 @@ public class AntenatalExaminationFacade { } } catch (Exception e) { } - String doctorId = antExChuModel.getProdDoctor(); - Users users= usersService.getUsers(Integer.valueOf(doctorId)); - Map map1 =new HashMap<>(); - if(null!=users){ - map1.put("id",users.getId()+""); - map1.put("name",users.getName()); + String doctorId = antExChuModel.getProdDoctor(); + Users users = usersService.getUsers(Integer.valueOf(doctorId)); + Map map1 = new HashMap<>(); + if (null != users) { + map1.put("id", users.getId() + ""); + map1.put("name", users.getName()); } antexChuResult.setProdDoctor(map1); ReferralApplyOrderQuery referralApplyOrderQuery = new ReferralApplyOrderQuery(); -- 1.8.3.1