From 7ef58d82169deabcaf56e727edf6f39d16bdf3c8 Mon Sep 17 00:00:00 2001 From: jiangjiazhi Date: Thu, 22 Dec 2016 16:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A7=E6=A3=80=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lyms/platform/biz/BasicConfigServiceTest.java | 41 +- .../com/lyms/platform/permission/model/Users.java | 20 + .../com/lyms/platform/pojo/AntExRecordModel.java | 10 + .../com/lyms/platform/query/AntExRecordQuery.java | 27 + .../controller/AntenatalExaminationController.java | 15 +- .../operate/web/controller/UsersController.java | 24 +- .../operate/web/facade/AntExRecordFacade.java | 48 +- .../web/facade/AntenatalExaminationFacade.java | 136 +- .../operate/web/facade/BookbuildingFacade.java | 2805 ++++++++++---------- .../operate/web/facade/MatDeliverFacade.java | 31 +- .../platform/operate/web/facade/PatientFacade.java | 4 +- .../operate/web/facade/PostReviewFacade.java | 166 +- 12 files changed, 1677 insertions(+), 1650 deletions(-) diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java index 99f4f37..22d280e 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java @@ -12,6 +12,7 @@ import com.lyms.platform.biz.service.*; 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.GroupEnums; import com.lyms.platform.common.enums.ServiceStatusEnums; import com.lyms.platform.common.enums.ServiceTypeEnums; import com.lyms.platform.common.enums.YnEnums; @@ -40,10 +41,46 @@ public class BasicConfigServiceTest { public static SimpleDateFormat h_m_s = new SimpleDateFormat("HH:mm:ss"); public static void main(String[] args) throws Exception { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml"); // queryRisk(applicationContext); - changeLong2Time(applicationContext); +// changeLong2Time(applicationContext); + + buildOrgGroup(applicationContext); + } + + + public static void buildOrgGroup(ApplicationContext applicationContext){ + + OrganizationGroupsService groupsService =applicationContext.getBean(OrganizationGroupsService.class); + OrganizationGroups groups=new OrganizationGroups(); + groups.setbType(GroupEnums.BuildType.REGION.getbType()); + groups.setGroupName("区域共享尼玛"); + groups.setOwner(10002); + groups.setCreated(new Date()); + groups.setModified(new Date()); + groupsService.addOneEntity(groups); + + + OrganizationGroupsItemService groupsItemService= applicationContext.getBean(OrganizationGroupsItemService.class); + OrganizationGroupsItems groupsItems=new OrganizationGroupsItems(); + groupsItems.setGroupId(groups.getId()); + groupsItems.setCreated(new Date()); + groupsItems.setModified(new Date()); + groupsItems.setType(1); + List list=new ArrayList<>(); + list.add(193); + list.add(195); + list.add(197); + list.add(204); + list.add(248); + list.add(1000000000); + list.add(1000000001); + groupsItems.sethId(list); + groupsItems.setParentId("100002"); + System.out.println(groupsItemService.addOneEntity(groupsItems)); + OrganizationGroupsItemQuery groupsItemQuery=new OrganizationGroupsItemQuery(); + List list1= groupsItemService.queryList(groupsItemQuery); + System.out.println(list1.size()); } public static void changeLong2Time(ApplicationContext applicationContext) { diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java index 2aa7b5f..1eef3ab 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/model/Users.java @@ -25,6 +25,26 @@ public class Users { private Integer zhiChenId; private String zhiChen; private String employeeId; + //当前医院所在是否是建档医院 + private Integer bStatus; + //当前方式 + private Integer bType; + + public Integer getbType() { + return bType; + } + + public void setbType(Integer bType) { + this.bType = bType; + } + + public Integer getbStatus() { + return bStatus; + } + + public void setbStatus(Integer bStatus) { + this.bStatus = bStatus; + } public String getEmployeeId() { return employeeId; diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/AntExRecordModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/AntExRecordModel.java index f90a36b..1add38d 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/AntExRecordModel.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/AntExRecordModel.java @@ -26,6 +26,8 @@ public class AntExRecordModel extends BaseModel { private String parentId; private String hospitalId; + //手机号 + private String phone; //状态 1 已分娩 2未分娩 private int status; //类型 1 初诊 2复诊 @@ -56,6 +58,14 @@ public class AntExRecordModel extends BaseModel { private Date created; + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + public String getfId() { return fId; } diff --git a/platform-dal/src/main/java/com/lyms/platform/query/AntExRecordQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/AntExRecordQuery.java index 6098a17..a1624d7 100644 --- a/platform-dal/src/main/java/com/lyms/platform/query/AntExRecordQuery.java +++ b/platform-dal/src/main/java/com/lyms/platform/query/AntExRecordQuery.java @@ -17,6 +17,33 @@ public class AntExRecordQuery extends BaseQuery implements IConvertToNativeQuery private String parentId; private String id; private String fId; + private String name; + private String cardNo; + private String phone; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCardNo() { + return cardNo; + } + + public void setCardNo(String cardNo) { + this.cardNo = cardNo; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } //创建时间 private String hospitalId; 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 8f53a00..05db676 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 @@ -10,6 +10,7 @@ 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.PropertiesUtils; +import com.lyms.platform.operate.web.facade.AntExRecordFacade; import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; import com.lyms.platform.operate.web.request.*; import org.apache.commons.lang.StringUtils; @@ -41,6 +42,8 @@ public class AntenatalExaminationController extends BaseController { @Autowired private QhdfyHisService qhdfyHisService; + @Autowired + private AntExRecordFacade antExRecordFacade; public static final String HIS_VERSION = PropertiesUtils.getPropertyValue("his_version"); @@ -165,6 +168,16 @@ public class AntenatalExaminationController extends BaseController { @TokenRequired public BaseResponse findAntExList(@Valid AntExListQueryRequest exListQueryRequest,HttpServletRequest request) { LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); - return antenatalExaminationFacade.findAntExListTwo(exListQueryRequest,loginState.getId()); + return antenatalExaminationFacade.findAntExListTwo(exListQueryRequest, loginState.getId()); + } + + /** + * 产检管理接口 + * + * @return + */ + public BaseResponse findAntEx(@Valid AntExManagerQueryRequest antExManagerQueryRequest){ + + return null; } } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java index 049e8f8..707f024 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java @@ -1,25 +1,25 @@ package com.lyms.platform.operate.web.controller; +import com.lyms.platform.biz.service.OrganizationGroupsService; import com.lyms.platform.common.annotation.TokenRequired; import com.lyms.platform.common.base.BaseController; import com.lyms.platform.common.base.LoginContext; import com.lyms.platform.common.base.PageInfo; import com.lyms.platform.common.constants.ConstantInterface; import com.lyms.platform.common.constants.ErrorCodeConstants; -import com.lyms.platform.common.enums.HospitalStatusEnums; -import com.lyms.platform.common.enums.UserTypeEnum; -import com.lyms.platform.common.enums.YnEnums; -import com.lyms.platform.common.enums.ZhiChenEnums; +import com.lyms.platform.common.enums.*; import com.lyms.platform.common.utils.*; import com.lyms.platform.operate.web.facade.AccessPermissionFacade; import com.lyms.platform.operate.web.facade.AutoMatchFacade; +import com.lyms.platform.operate.web.facade.OrganizationGroupsFacade; import com.lyms.platform.operate.web.result.FrontEndResult; import com.lyms.platform.operate.web.session.SessionProvider; import com.lyms.platform.operate.web.session.strategy.ISessionProvider; import com.lyms.platform.permission.model.*; import com.lyms.platform.permission.service.*; import com.lyms.platform.pojo.DataPermissionsModel; +import com.lyms.platform.pojo.OrganizationGroups; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.*; @@ -47,7 +47,7 @@ public class UsersController extends BaseController { @Autowired private UsersService usersService; @Autowired - private TokenService tokenService; + private OrganizationGroupsFacade groupsFacade; @Autowired private UserRoleMapsService userRoleMapsService; @Autowired @@ -65,7 +65,7 @@ public class UsersController extends BaseController { @Value("#{configProperties['defaultAdminOrgId']}") private String defaultAdminOrgId; @Autowired - private RolePermissionMapsService rolePermissionMapsService; + private OrganizationGroupsService groupsService; @Autowired private Permissions2Service permissions2Service; @Autowired @@ -481,6 +481,18 @@ public class UsersController extends BaseController { Organization organization = organizationService.getOrganization(users.getOrgId()); organizations.add(organization); users.setOrganization(organization); + //是否是建档医院 + users.setbStatus(organization.getbStatus()); + //设置建档方式 + String groupId= groupsFacade.findByCurrentUserId(loginContext.getId()+""); + Integer bType= GroupEnums.BuildType.SINGLE.getbType(); + if(StringUtils.isNotEmpty(groupId)){ + OrganizationGroups groups= groupsService.findById(groupId); + if(null!=groups){ + bType= groups.getbType(); + } + } + users.setbType(bType); List list2 = accessPermissionFacade.getOrganization(permissionsModelList); if (CollectionUtils.isNotEmpty(list2)) { for (Organization o : list2) { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java index 3178720..02dfd05 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntExRecordFacade.java @@ -12,7 +12,9 @@ import com.lyms.platform.common.utils.DateUtil; import com.lyms.platform.common.utils.ExceptionUtils; import com.lyms.platform.common.utils.JsonUtil; import com.lyms.platform.common.utils.StringUtils; +import com.lyms.platform.operate.web.request.AntExManagerQueryRequest; import com.lyms.platform.operate.web.request.CjStatisticsQueryRequest; +import com.lyms.platform.operate.web.result.AntExManagerResult; import com.lyms.platform.operate.web.result.CjStatisticsListResult; import com.lyms.platform.operate.web.result.CjStatisticsResult; import com.lyms.platform.operate.web.result.HighScoreResult; @@ -54,6 +56,34 @@ public class AntExRecordFacade { } /** + * 产检管理 + * + * @return + */ + public BaseResponse findList(AntExManagerQueryRequest antExManagerQueryRequest, Integer userId) { + + String hospitalId = autoMatchFacade.getHospitalId(userId); + AntExRecordQuery antExRecordQuery = new AntExRecordQuery(); + antExRecordQuery.setHospitalId(hospitalId); + antExRecordQuery.setNeed("1"); + antExRecordQuery.setPage(antExManagerQueryRequest.getPage()); + antExRecordQuery.setLimit(antExManagerQueryRequest.getLimit()); + antExRecordQuery.setName(antExManagerQueryRequest.getName()); + antExRecordQuery.setPhone(antExManagerQueryRequest.getPhone()); + + + List data =new ArrayList<>(); + List antExRecordModelList = recordService.queryAntExRecords(antExRecordQuery); + if (CollectionUtils.isNotEmpty(antExRecordModelList)) { + for (AntExRecordModel e : antExRecordModelList) { + AntExManagerResult antExManagerResult = new AntExManagerResult(); + antExManagerResult.convertToResult(e); + } + } + return new BaseListResponse().setData(data).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + } + + /** * 产检统计 * * @param userId @@ -114,9 +144,9 @@ public class AntExRecordFacade { Patients patients = patientsService.findOnePatientById(record.getParentId()); String dueWeek = ""; if (null != patients) { - if (patients.getDueStatus()!=null&&patients.getDueStatus() == 1&&patients.getType()==3) { + if (patients.getDueStatus() != null && patients.getDueStatus() == 1 && patients.getType() == 3) { dueWeek = "终止妊娠"; - } else if (patients.getType()==3) { + } else if (patients.getType() == 3) { dueWeek = "已分娩"; } else { int days = DateUtil.daysBetween(patients.getLastMenses(), new Date()); @@ -153,7 +183,7 @@ public class AntExRecordFacade { List level = new ArrayList(); try { for (Object str : record.gethLevel()) { - if(null!=str&&StringUtils.isNotEmpty(str.toString())){ + if (null != str && StringUtils.isNotEmpty(str.toString())) { BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str.toString()); if (null != basicConfig) { Map map = new HashMap(); @@ -180,20 +210,20 @@ public class AntExRecordFacade { List list = recordService.aggregateOne(antExRecordQuery); for (HashMap map : list) { CjStatisticsResult cjStatisticsResult = new CjStatisticsResult(); - String dId=null; + String dId = null; Object id = map.get("_id"); - if(null!=id){ - dId =id.toString(); - }else { + if (null != id) { + dId = id.toString(); + } else { continue; } cjStatisticsResult.setdId(dId); cjStatisticsResult.setCount(map.get("count").toString()); try { - if(null==dId){ + if (null == dId) { cjStatisticsResult.setdName("未知"); - }else{ + } else { Users users = usersService.getUsers(Integer.valueOf(dId)); if (null != users) { cjStatisticsResult.setdName(users.getName()); 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 ce2474f..8438ade 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 @@ -62,6 +62,10 @@ public class AntenatalExaminationFacade { private AntExRecordService recordService; @Value(("#{configProperties['run.region']}")) private String runType; + + @Autowired + private OrganizationGroupsFacade groupsFacade; + /** * 处理区域隐藏建档 * @@ -76,8 +80,9 @@ public class AntenatalExaminationFacade { if (StringUtils.isNotEmpty(parentId)) { return parentId; } - - Patients patients = findOnePatient(null, null, null, hospitalId, 1, false, pid, true); + List li = new ArrayList(); + li.add(hospitalId); + Patients patients = findOnePatient(null, null, null, li, 1, false, pid, true); //表示本院已经有隐藏建档 if (null != patients) { return patients.getId(); @@ -99,6 +104,7 @@ public class AntenatalExaminationFacade { } return null; } + /** * 修改最后一次产检时间 * @@ -106,38 +112,39 @@ public class AntenatalExaminationFacade { */ private void setLashCTimes(String id) { - AntExQuery antExQuery = new AntExQuery(); - antExQuery.setParentId(id); - antExQuery.setYn(YnEnums.YES.getId()); - Date date=null; - List antEx = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); - if (CollectionUtils.isNotEmpty(antEx)) { - date= antEx.get(0).getCheckDate(); - } else { - AntExChuQuery antExChuQuery = new AntExChuQuery(); - antExChuQuery.setParentId(id); - antExChuQuery.setYn(YnEnums.YES.getId()); - List antExChu = antenatalExaminationService.queryAntExChu(antExChuQuery); - if (CollectionUtils.isNotEmpty(antExChu)) { - date= antExChu.get(0).getCheckTime(); - } + AntExQuery antExQuery = new AntExQuery(); + antExQuery.setParentId(id); + antExQuery.setYn(YnEnums.YES.getId()); + Date date = null; + List antEx = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); + if (CollectionUtils.isNotEmpty(antEx)) { + date = antEx.get(0).getCheckDate(); + } else { + AntExChuQuery antExChuQuery = new AntExChuQuery(); + antExChuQuery.setParentId(id); + antExChuQuery.setYn(YnEnums.YES.getId()); + List antExChu = antenatalExaminationService.queryAntExChu(antExChuQuery); + if (CollectionUtils.isNotEmpty(antExChu)) { + date = antExChu.get(0).getCheckTime(); } + } - if (null!=date) { + if (null != date) { Patients patients1 = new Patients(); patients1.setLastCTime(date); patients1.setId(id); patientsService.updatePatient(patients1); } } + //当非建档医院修改初诊信息时,需要同步给建档医院 - private void syncMaster(String parentId){ + private void syncMaster(String parentId) { //当前非建档医院最新的状态 Patients patients = patientsService.findOnePatientById(parentId); - if(StringUtils.isNotEmpty(patients.getSource())){ - Patients masterPatients =patientsService.findOnePatientById(patients.getSource()); + if (StringUtils.isNotEmpty(patients.getSource())) { + Patients masterPatients = patientsService.findOnePatientById(patients.getSource()); masterPatients.setoRiskFactor(patients.getoRiskFactor()); masterPatients.setLastCTime(patients.getLastCTime()); @@ -225,7 +232,7 @@ public class AntenatalExaminationFacade { //修改数据 syncMaster(antExAddRequest.getParentId()); //复诊,修改产检管理 - antenatalExaminationService.updateAntExRecord(model.getId(),2); + antenatalExaminationService.updateAntExRecord(model.getId(), 2); if (null != patients.getBuildType() && patients.getBuildType() == 3) { ReferralApplyOrderQuery referralApplyOrderQuery = new ReferralApplyOrderQuery(); referralApplyOrderQuery.setParentId(patients.getId()); @@ -301,7 +308,7 @@ public class AntenatalExaminationFacade { antExChuModel.setHospitalId(hospitalId); antenatalExaminationService.updateAntExChu(antExChuModel, antExChuModel.getId()); - antenatalExaminationService.updatePatientAbortion(antExChuModel.getId(),antExChuModel.getAbortionZR(), antExChuModel.getAbortionRG()); + antenatalExaminationService.updatePatientAbortion(antExChuModel.getId(), antExChuModel.getAbortionZR(), antExChuModel.getAbortionRG()); Patients patients = patientsService.findOnePatientById(excAddRequest.getParentId()); patients.setLastCheckEmployeeId(excAddRequest.getProdDoctor()); @@ -323,7 +330,7 @@ public class AntenatalExaminationFacade { //初诊,修改产检管理 // antenatalExaminationService.updateAntExRecord(antExChuModel.getId(), 1); - if(StringUtils.isNotEmpty(antExChuModel.getPid())) { + if (StringUtils.isNotEmpty(antExChuModel.getPid())) { recordService.handExRecord(antExChuModel.getPid()); } } else { @@ -366,7 +373,7 @@ public class AntenatalExaminationFacade { //修改本院最后一次定义高危 updateLastRhTime(patients.getId(), hospitalId); setLashCTimes(antExChuModel.getParentId()); - if(StringUtils.isNotEmpty(antExChuModel.getPid())){ + if (StringUtils.isNotEmpty(antExChuModel.getPid())) { recordService.handExRecord(antExChuModel.getPid()); } if (null != patients.getBuildType() && patients.getBuildType() == 3) { @@ -832,9 +839,10 @@ public class AntenatalExaminationFacade { List sortList = new ArrayList(); String hospital = autoMatchFacade.getHospitalId(userId); List listDate = new ArrayList(); - + ; if (CollectionUtils.isNotEmpty(list)) { - Patients patients2 = findOnePatient(null, null, null, hospital, -1, true, exListQueryRequest.getPid(),false); +// Patients patients2 = findOnePatient(null, null, null, hospital, -1, true, exListQueryRequest.getPid(),false); + Patients patients2 = findOnePatient(null, null, null, groupsFacade.findGroupHospital(userId), -1, true, exListQueryRequest.getPid(), false); antexListResult.convertToResult(null, patients2, null); HighScoreResult highScoreResult = findLastRisk(list.get(0).getPid(), false); @@ -1038,9 +1046,9 @@ public class AntenatalExaminationFacade { AntExChuQuery antExChuQuery = new AntExChuQuery(); antExChuQuery.setYn(YnEnums.YES.getId()); antExChuQuery.setStart(patients.getBookbuildingDate()); - if(null==patients.getFmDate()){ - antExChuQuery.setEnd(new Date(DateUtil.addWeek(patients.getLastMenses(), 42).getTime()+ 86398000)); - }else{ + if (null == patients.getFmDate()) { + antExChuQuery.setEnd(new Date(DateUtil.addWeek(patients.getLastMenses(), 42).getTime() + 86398000)); + } else { antExChuQuery.setEnd(new Date(patients.getFmDate().getTime() + 86398000)); } @@ -1061,9 +1069,9 @@ public class AntenatalExaminationFacade { antExQuery.setYn(YnEnums.YES.getId()); antExQuery.setPid(pid); antExQuery.setStart(patients.getBookbuildingDate()); - if(null==patients.getFmDate()){ - antExQuery.setEnd(new Date(DateUtil.addWeek(patients.getLastMenses(), 42).getTime()+ 86398000)); - }else{ + if (null == patients.getFmDate()) { + antExQuery.setEnd(new Date(DateUtil.addWeek(patients.getLastMenses(), 42).getTime() + 86398000)); + } else { antExQuery.setEnd(new Date(patients.getFmDate().getTime() + 86398000)); } @@ -1160,10 +1168,10 @@ public class AntenatalExaminationFacade { return -1; } if (Integer.valueOf(o1.getType()) == Integer.valueOf(o2.getType())) { - if (o1.getCreated().getTime()(o2.getCreated().getTime())) { + if (o1.getCreated().getTime() > (o2.getCreated().getTime())) { return 1; } } @@ -1227,7 +1235,7 @@ public class AntenatalExaminationFacade { } } - List list1 = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC,"checkDate")); + List list1 = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); if (CollectionUtils.isNotEmpty(list1)) { for (AntenatalExaminationModel an : list1) { if (null != an.getHospitalId()) { @@ -1464,7 +1472,7 @@ public class AntenatalExaminationFacade { AntenatalExaminationModel localAntModel = antenatalExaminationService.findOneById(antExQueryRequest.getId()); - parentId =localAntModel.getParentId(); + parentId = localAntModel.getParentId(); /*AntExQuery antExQuery = new AntExQuery(); antExQuery.setId(antExQueryRequest.getId()); @@ -1493,7 +1501,7 @@ public class AntenatalExaminationFacade { //修改最后一次检查时间 AntenatalExaminationModel antenatalExaminationModel = antenatalExaminationService.findOneById(antExQueryRequest.getId()); - setLashCTimes( antenatalExaminationModel.getParentId()); + setLashCTimes(antenatalExaminationModel.getParentId()); updateLastRisk(antenatalExaminationModel.getParentId()); recordService.handExRecord(antenatalExaminationModel.getParentId()); @@ -1552,14 +1560,12 @@ public class AntenatalExaminationFacade { //删除复诊或者出诊的时候更新patient表的下次预约时间为最近的一次预约 - if (StringUtils.isNotEmpty(parentId)) - { + if (StringUtils.isNotEmpty(parentId)) { PatientsQuery patientQuery = new PatientsQuery(); patientQuery.setYn(YnEnums.YES.getId()); patientQuery.setId(parentId); List patientses = patientsService.queryPatient(patientQuery); - if (CollectionUtils.isNotEmpty(patientses)) - { + if (CollectionUtils.isNotEmpty(patientses)) { for (Patients pat : patientses) { AntExChuQuery antExChuQuery = new AntExChuQuery(); antExChuQuery.setYn(YnEnums.YES.getId()); @@ -1568,21 +1574,18 @@ public class AntenatalExaminationFacade { Date nextTime = null; List chus = antenatalExaminationService.queryAntExChu(antExChuQuery); if (CollectionUtils.isNotEmpty(chus)) { - AntExChuModel chu = chus.get(0); - if (chu != null) - { + AntExChuModel chu = chus.get(0); + if (chu != null) { nextTime = chu.getNextCheckTime(); AntExQuery antExQuery = new AntExQuery(); antExQuery.setParentId(pat.getId()); antExQuery.setYn(YnEnums.YES.getId()); antExQuery.setHospitalId(pat.getHospitalId()); - List list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); - if (CollectionUtils.isNotEmpty(list)) - { - AntenatalExaminationModel ae = list.get(0); - if (ae != null) - { + List list = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); + if (CollectionUtils.isNotEmpty(list)) { + AntenatalExaminationModel ae = list.get(0); + if (ae != null) { nextTime = ae.getNextCheckTime(); } } @@ -1629,7 +1632,7 @@ public class AntenatalExaminationFacade { * @param type 类型 1 孕妇 3 产妇 -1 不区分 * @param outHospital 是否需要查外院 */ - public Patients findOnePatient(String cardNo, String vcCardNo, String id, String hospitalId, Integer type, boolean outHospital, String pid, boolean isEnable) { + public Patients findOnePatient(String cardNo, String vcCardNo, String id, List hospitalId, Integer type, boolean outHospital, String pid, boolean isEnable) { PatientsQuery patientsQuery = new PatientsQuery(); if (StringUtils.isNotEmpty(cardNo)) { patientsQuery.setCardNo(cardNo); @@ -1641,7 +1644,7 @@ public class AntenatalExaminationFacade { patientsQuery.setPid(pid); } patientsQuery.setType(type); - patientsQuery.setHospitalId(hospitalId); + patientsQuery.setHospitalList(hospitalId); patientsQuery.setYn(YnEnums.YES.getId()); patientsQuery.setBuildType(1); if (isEnable) { @@ -1699,6 +1702,7 @@ public class AntenatalExaminationFacade { public BaseResponse queryAntenatalExamination(AntenatalExaminationQueryRequest queryRequest, Integer userId) { String hospitalId = autoMatchFacade.getHospitalId(userId); Patients patients = null; + Organization og = organizationService.getOrganization(Integer.valueOf(hospitalId)); if (!StringUtils.isEmpty(queryRequest.getPatientId())) { PatientsQuery patientsQuery = new PatientsQuery(); patientsQuery.setId(queryRequest.getPatientId()); @@ -1711,23 +1715,21 @@ public class AntenatalExaminationFacade { } else { //区域模式 - if (ErrorCodeConstants.RUN_MODE.equals(runType)) { - patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, hospitalId, 1, false, null, true); - } else { - //查询产妇数据 - patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, hospitalId, 1, false, null, false); - } + + patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, groupsFacade.findGroupHospital(userId), 1, false, null, og.getbStatus() == 1); + //查询产妇数据 +// patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, hospitalId, 1, false, null, false); } if (null == patients) { - if (ErrorCodeConstants.RUN_MODE.equals(runType)) { - //查询是否还有其他记录 - patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, hospitalId, 3, false, null, true); - } else { - //查询是否还有其他记录 - patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, hospitalId, 3, false, null, false); - } - +// if (ErrorCodeConstants.RUN_MODE.equals(runType)) { +// //查询是否还有其他记录 +// patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, hospitalId, 3, false, null, true); +// } else { +// //查询是否还有其他记录 +// patients = findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, hospitalId, 3, false, null, false); +// } + patients=findOnePatient(queryRequest.getCardNo(), queryRequest.getVcCardNo(), null, groupsFacade.findGroupHospital(userId), 3, false, null, og.getbStatus() == 1); //区域模式 if (ErrorCodeConstants.RUN_MODE.equals(runType)) { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java index 8df83f9..7408a78 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java @@ -45,428 +45,383 @@ import java.util.*; @Component public class BookbuildingFacade { - private Logger logger = LoggerFactory.getLogger(BookbuildingFacade.class); - public static final String HIS_VERSION = PropertiesUtils.getPropertyValue("his_version"); - - @Autowired - private YunBookbuildingService yunBookbuildingService; - - @Autowired - private BasicConfigFacade basicConfigFacade; - - @Autowired - private OrganizationService organizationService; - - - @Autowired - private PersonService personService; - - @Autowired - private SmsTemplateService smsTemplateService; - - - @Autowired - private AntenatalExaminationService antenatalExaminationService; - - @Autowired - private AutoMatchFacade autoMatchFacade; - - @Autowired - private UsersService usersService; - - @Autowired - private PatientsService patientsService; - - @Autowired - private BasicConfigService basicConfigService; - - @Autowired - private AntenatalExaminationFacade antenatalExaminationFacade; - - @Autowired - private SmsConfigFacade smsConfigFacade; - - @Autowired - private HisService hisServiceV2; - - @Autowired - private QingLongXianHisService qingLongXianHisService; - - @Autowired - private FnfyHisService fnfyHisService; - @Autowired - private QhdfyHisService qhdfyHisService; - - - @Autowired - private DeleteProcessHandler deleteProcessHandler; - - @Autowired - private SyncDataService syncDataService; - @Autowired - private SieveService sieveService; - @Value(("#{configProperties['run.region']}")) - private String runType; - - /** - * 添加孕妇建档 - * @param yunRequest - * @return - */ - public BaseObjectResponse addPregnantBookbuilding( - YunBookbuildingAddRequest yunRequest,Integer userId) { - - BaseObjectResponse br = new BaseObjectResponse(); - PatientsQuery patientsQuery = new PatientsQuery(); - patientsQuery.setYn(YnEnums.YES.getId()); - patientsQuery.setType(1); - patientsQuery.setHospitalId(yunRequest.getHospitalId()); - patientsQuery.setBuildTypeEq(0); - patientsQuery.setDueStatus(0); - - if (yunRequest.getPregnantCertificateNum() != null) - { - patientsQuery.setCardNo(yunRequest.getPregnantCertificateNum()); - //判断该身份证号码是否有孕妇建档 在该医院 - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) - { - br.setErrorcode(ErrorCodeConstants.DATA_EXIST); - br.setErrormsg("该身份证在医院已经建档"); - return br; - } - } - if (yunRequest.getPregnantPhone() != null) - { - patientsQuery.setCardNo(null); - patientsQuery.setPhone(yunRequest.getPregnantPhone()); - //判断该手机号码在 孕期内有没有建档 - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) - { - br.setErrorcode(ErrorCodeConstants.DATA_EXIST); - br.setErrormsg("该手机号码已经建档"); - return br; - } - } - - //就诊卡号判断 - if (StringUtils.isNotEmpty(yunRequest.getVcCardNo())) - { - patientsQuery.setCardNo(null); - patientsQuery.setPhone(null); - patientsQuery.setVcCardNo(yunRequest.getVcCardNo()); - patientsQuery.setHospitalId(yunRequest.getHospitalId()); - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) - { - br.setErrorcode(ErrorCodeConstants.DATA_EXIST); - br.setErrormsg("该就诊卡号在该医院已经建档"); - return br; - } - } - - Integer type = 1; //1孕妇 2儿童 3产妇 - //建档类型 0 未分娩建档 1儿童建档时建档 2 自动分娩类型 3 转诊自动建档 - Integer buildType = 0; - Date date = null; - if (yunRequest.getLastMenstrualPeriod() != null) - { - date = DateUtil.addWeek(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()),42); - Date currentDate = DateUtil.formatDate(new Date()); - if (date.getTime() <= currentDate.getTime()) - { - type = 3; - buildType = 2; - } - } - - PersonModel resperson = null; - if (StringUtils.isNotEmpty(yunRequest.getPregnantCertificateNum())) - { - - PersonModelQuery personModelQuery = new PersonModelQuery(); - personModelQuery.setCardNo(yunRequest.getPregnantCertificateNum()); - personModelQuery.setYn(YnEnums.YES.getId()); - personModelQuery.setTypes(new Integer[]{1,3}); //孕妇或者产妇基本信息 - List personModels = personService.queryPersons(personModelQuery); - - PersonModel pmodel = new PersonModel(); - pmodel.setName(yunRequest.getPregnantName()); - pmodel.setBirth(DateUtil.parseYMD(yunRequest.getBirthday())); - pmodel.setPhone(yunRequest.getPregnantPhone()); - pmodel.setCardNo(yunRequest.getPregnantCertificateNum()); - pmodel.setType(type); - pmodel.setModified(new Date()); - if (CollectionUtils.isNotEmpty(personModels) && personModels.get(0) != null) - { - - resperson = personModels.get(0); - personService.updatePerson(pmodel,personModels.get(0).getId()); - } - else - { - pmodel.setYn(YnEnums.YES.getId()); - pmodel.setCreated(new Date()); - resperson = personService.addPerson(pmodel); - } - } - - Patients patient = getPatientsData(yunRequest); - patient.setDueStatus(0); - //1孕妇 3 产妇 - patient.setType(type); - patient.setBuildType(buildType); - if (type == ServiceObjEnums.CHANOBJ.getId() && date != null) - { - patient.setFmDate(date); - } - if (resperson != null) - { - patient.setPid(resperson.getId()); - HighScoreResult highScoreResult= antenatalExaminationFacade.findLastRisk(resperson.getId(), true); - if(CollectionUtils.isNotEmpty(highScoreResult.getHighId())){ - patient.setRiskFactorId(highScoreResult.getHighId()); - } - patient.setRiskScore(highScoreResult.getScore()); - if(CollectionUtils.isNotEmpty(highScoreResult.getLevelId())){ - patient.setRiskLevelId(JsonUtil.array2JsonString(highScoreResult.getLevelId())); - } - } - - patient.setCreated(new Date()); - patient.setModified(new Date()); - patient.setOperator(userId); - Patients p = yunBookbuildingService.addPregnantBookbuilding(patient); - - if (p == null || p.getId() == null) - { - br.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); - br.setErrormsg("建档失败,保存异常"); - return br; - - } - - //加入产筛 - patientsService.validata(p); - - if (type == ServiceObjEnums.YUNOBJ.getId()) - { - //生成建档短信 - createBuildSms(p); - } - - br.setErrorcode(ErrorCodeConstants.SUCCESS); - br.setErrormsg("成功"); - br.setData(p.getId()); - return br; - - } - - /** - * 创建孕妇建档短信 - */ - private void createBuildSms(Patients patient) - { - - //判断医院是否启动和对应的服务项是否启用 - SmsConfigModel configModel = new SmsConfigModel(); - BaseResponse response = smsConfigFacade.hospitalIsStart(patient.getHospitalId(),configModel,SmsServiceEnums.FWKT.getId()); - if (response != null) - { - return; - } - - SmsTemplateQuery query = new SmsTemplateQuery(); - query.setYn(YnEnums.YES.getId()); - query.setStatus(1); - query.setHospitalId(patient.getHospitalId()); - query.setServiceObj(ServiceObjEnums.YUNOBJ.getId()); - query.setSpecialDateType(SpecialDateEnums.JD.getId()); - - Integer serviceType = patient.getServiceType(); - Integer serviceStatus = patient.getServiceStatus(); - - List sendList = new ArrayList<>(); - - List temps = smsTemplateService.querySmsTemplates(query); - if (CollectionUtils.isNotEmpty(temps)) - { - - for (SmsTemplateModel temp : temps) - { - if (temp.getServiceType() == serviceType && temp.getServiceStatus() == serviceStatus) - { - sendList.add(temp); - } - else if (temp.getServiceType() == serviceType && temp.getServiceStatus() == serviceStatus) - { - sendList.add(temp); - } - else if (temp.getServiceStatus() == ServiceStatusEnums.ADD_ALL.getId()) - { - if (serviceStatus == ServiceStatusEnums.ADD_OPEN.getId() || serviceStatus == ServiceStatusEnums.UNSUBSCRIBE.getId() - || serviceStatus == ServiceStatusEnums.ADD_OVERDUE.getId()|| serviceStatus == ServiceStatusEnums.SUSPEND.getId()) - { - sendList.add(temp); - } - } - else if (temp.getServiceStatus() == ServiceStatusEnums.ALL_OPEN.getId()) - { - if (serviceStatus == ServiceStatusEnums.STANDARD_OPEN.getId() || serviceStatus == ServiceStatusEnums.ADD_OPEN.getId() ) - { - sendList.add(temp); - } - } - else if (temp.getServiceStatus() == ServiceStatusEnums.ALL_OVERDUE.getId()) - { - if (serviceStatus == ServiceStatusEnums.STANDARD_OVERDUE.getId() || serviceStatus == ServiceStatusEnums.ADD_OVERDUE.getId() ) - { - sendList.add(temp); - } - } - else if (temp.getServiceType() == ServiceTypeEnums.ALL_SERVICE.getId() && temp.getServiceStatus() == ServiceStatusEnums.ALL.getId()) - { - sendList.add(temp); - } - } - - if (CollectionUtils.isNotEmpty(sendList)) - { - - //短信前缀 - String messagePrefix = smsConfigFacade.getSmsPrefix(configModel, patient.getBookbuildingDoctor()); - for (SmsTemplateModel templateModel : sendList) - { - if (templateModel != null && templateModel.getStatus() == 1) - { - MessageListRequest smsList = new MessageListRequest(); - List messages = new ArrayList<>(); - MessageRequest mr = new MessageRequest(); - Date dueDate = DateUtil.addDay(patient.getLastMenses(), 7); - dueDate = DateUtil.addMonth(dueDate, 9); - String content = StringUtils.replaceEL(patient.getUsername(),dueDate,templateModel.getContent()); - - mr.setContent("【"+messagePrefix+"】"+content); - mr.setObjType(ServiceObjEnums.YUNOBJ.getId()); - mr.setPhone(patient.getPhone()); - mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); - //短信商 - mr.setServiceType(SmsProviderEnums.YM.getId()); - mr.setTypeId(ProjectTypeEnums.YNXT.getId()); - mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); - mr.setSubTypeId(SmsServiceEnums.FWKT.getId()); - mr.setStatus(SmsStatusEnums.WFS.getId()); - mr.setExt1(patient.getHospitalId()); - mr.setExt2(templateModel.getId()); - mr.setExt3(patient.getId()); - messages.add(mr); - - if (CollectionUtils.isNotEmpty(messages)) { - smsList.setTypeId(ProjectTypeEnums.YNXT.getId()); - smsList.setMessages(messages); - //调用发送接口 - if (!syncDataService.savePostMsg(JsonUtil.obj2JsonString(smsList), messages.get(0).getExt1())) { - MessageCenterService.saveSmsCenter(smsList); - } - } - } - } - } - } - } - - - /** - * 判断对应服务是否启动 - */ - private boolean isStartService(Integer smsType,String serviceStr) - { - if (StringUtils.isEmpty(serviceStr)) - { - return false; - } - //消息服务启动 - List smsServices = JsonUtil.toList(serviceStr, Map.class); - - if (CollectionUtils.isNotEmpty(smsServices)) - { - for (Map map : smsServices) - { - String status = String.valueOf(map.get(String.valueOf(smsType))); - if ("true".equals(status)) - { - return true; - } - } - } - return false; - } - - /** - * 更新孕妇信息 - * @param id - * @param yunRequest - */ - public BaseResponse updatePregnantById(String id, YunBookbuildingAddRequest yunRequest,Integer userId) { - - - BaseResponse br = new BaseResponse(); - PatientsQuery patientsQuery = new PatientsQuery(); - patientsQuery.setYn(YnEnums.YES.getId()); - patientsQuery.setType(1); - patientsQuery.setHospitalId(yunRequest.getHospitalId()); - patientsQuery.setBuildTypeEq(0); - patientsQuery.setDueStatus(0); - - if (yunRequest.getPregnantCertificateNum() != null) - { - patientsQuery.setCardNo(yunRequest.getPregnantCertificateNum()); - //判断该身份证号码是否有孕妇建档 在该医院 - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) - { - Patients pat = patients.get(0); - if (pat != null && !pat.getPhone().equals(yunRequest.getPregnantPhone())) - { - if (StringUtils.isNotEmpty(yunRequest.getPregnantPhone())) { - patientsQuery.setCardNo(null); - patientsQuery.setPhone(yunRequest.getPregnantPhone()); - //判断该手机号码在 孕期内有没有建档 - patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) { - br.setErrorcode(ErrorCodeConstants.DATA_EXIST); - br.setErrormsg("该手机号码已经建档"); - return br; - } - } - } - - if (pat != null && StringUtils.isNotEmpty(pat.getVcCardNo()) && !pat.getVcCardNo().equals(yunRequest.getVcCardNo())) - { - - //就诊卡号判断 - if (StringUtils.isNotEmpty(yunRequest.getVcCardNo())) - { - patientsQuery.setCardNo(null); - patientsQuery.setPhone(null); - patientsQuery.setVcCardNo(yunRequest.getVcCardNo()); - patientsQuery.setHospitalId(yunRequest.getHospitalId()); - patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) - { - br.setErrorcode(ErrorCodeConstants.DATA_EXIST); - br.setErrormsg("该就诊卡号在该医院已经建档"); - return br; - } - } - } - } - } - - - Patients patient = getPatientsData(yunRequest); - patient.setModified(new Date()); + private Logger logger = LoggerFactory.getLogger(BookbuildingFacade.class); + public static final String HIS_VERSION = PropertiesUtils.getPropertyValue("his_version"); + + @Autowired + private YunBookbuildingService yunBookbuildingService; + + @Autowired + private BasicConfigFacade basicConfigFacade; + + @Autowired + private OrganizationService organizationService; + + + @Autowired + private PersonService personService; + + @Autowired + private SmsTemplateService smsTemplateService; + + + @Autowired + private AntenatalExaminationService antenatalExaminationService; + + @Autowired + private AutoMatchFacade autoMatchFacade; + + @Autowired + private UsersService usersService; + + @Autowired + private PatientsService patientsService; + + @Autowired + private BasicConfigService basicConfigService; + + @Autowired + private AntenatalExaminationFacade antenatalExaminationFacade; + + @Autowired + private SmsConfigFacade smsConfigFacade; + + @Autowired + private HisService hisServiceV2; + + @Autowired + private QingLongXianHisService qingLongXianHisService; + + @Autowired + private FnfyHisService fnfyHisService; + @Autowired + private QhdfyHisService qhdfyHisService; + + + @Autowired + private DeleteProcessHandler deleteProcessHandler; + + @Autowired + private SyncDataService syncDataService; + @Autowired + private SieveService sieveService; + @Autowired + private OrganizationGroupsFacade groupsFacade; + + + /** + * 添加孕妇建档 + * + * @param yunRequest + * @return + */ + public BaseObjectResponse addPregnantBookbuilding( + YunBookbuildingAddRequest yunRequest, Integer userId) { + + BaseObjectResponse br = new BaseObjectResponse(); + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setType(1); + patientsQuery.setHospitalId(yunRequest.getHospitalId()); + patientsQuery.setBuildTypeEq(0); + patientsQuery.setDueStatus(0); + + if (yunRequest.getPregnantCertificateNum() != null) { + patientsQuery.setCardNo(yunRequest.getPregnantCertificateNum()); + //判断该身份证号码是否有孕妇建档 在该医院 + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); + br.setErrormsg("该身份证在医院已经建档"); + return br; + } + } + if (yunRequest.getPregnantPhone() != null) { + patientsQuery.setCardNo(null); + patientsQuery.setPhone(yunRequest.getPregnantPhone()); + //判断该手机号码在 孕期内有没有建档 + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); + br.setErrormsg("该手机号码已经建档"); + return br; + } + } + + //就诊卡号判断 + if (StringUtils.isNotEmpty(yunRequest.getVcCardNo())) { + patientsQuery.setCardNo(null); + patientsQuery.setPhone(null); + patientsQuery.setVcCardNo(yunRequest.getVcCardNo()); + patientsQuery.setHospitalId(yunRequest.getHospitalId()); + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); + br.setErrormsg("该就诊卡号在该医院已经建档"); + return br; + } + } + + Integer type = 1; //1孕妇 2儿童 3产妇 + //建档类型 0 未分娩建档 1儿童建档时建档 2 自动分娩类型 3 转诊自动建档 + Integer buildType = 0; + Date date = null; + if (yunRequest.getLastMenstrualPeriod() != null) { + date = DateUtil.addWeek(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod()), 42); + Date currentDate = DateUtil.formatDate(new Date()); + if (date.getTime() <= currentDate.getTime()) { + type = 3; + buildType = 2; + } + } + + PersonModel resperson = null; + if (StringUtils.isNotEmpty(yunRequest.getPregnantCertificateNum())) { + + PersonModelQuery personModelQuery = new PersonModelQuery(); + personModelQuery.setCardNo(yunRequest.getPregnantCertificateNum()); + personModelQuery.setYn(YnEnums.YES.getId()); + personModelQuery.setTypes(new Integer[]{1, 3}); //孕妇或者产妇基本信息 + List personModels = personService.queryPersons(personModelQuery); + + PersonModel pmodel = new PersonModel(); + pmodel.setName(yunRequest.getPregnantName()); + pmodel.setBirth(DateUtil.parseYMD(yunRequest.getBirthday())); + pmodel.setPhone(yunRequest.getPregnantPhone()); + pmodel.setCardNo(yunRequest.getPregnantCertificateNum()); + pmodel.setType(type); + pmodel.setModified(new Date()); + if (CollectionUtils.isNotEmpty(personModels) && personModels.get(0) != null) { + + resperson = personModels.get(0); + personService.updatePerson(pmodel, personModels.get(0).getId()); + } else { + pmodel.setYn(YnEnums.YES.getId()); + pmodel.setCreated(new Date()); + resperson = personService.addPerson(pmodel); + } + } + + Patients patient = getPatientsData(yunRequest); + patient.setDueStatus(0); + //1孕妇 3 产妇 + patient.setType(type); + patient.setBuildType(buildType); + if (type == ServiceObjEnums.CHANOBJ.getId() && date != null) { + patient.setFmDate(date); + } + if (resperson != null) { + patient.setPid(resperson.getId()); + HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(resperson.getId(), true); + if (CollectionUtils.isNotEmpty(highScoreResult.getHighId())) { + patient.setRiskFactorId(highScoreResult.getHighId()); + } + patient.setRiskScore(highScoreResult.getScore()); + if (CollectionUtils.isNotEmpty(highScoreResult.getLevelId())) { + patient.setRiskLevelId(JsonUtil.array2JsonString(highScoreResult.getLevelId())); + } + } + + patient.setCreated(new Date()); + patient.setModified(new Date()); + patient.setOperator(userId); + Patients p = yunBookbuildingService.addPregnantBookbuilding(patient); + + if (p == null || p.getId() == null) { + br.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); + br.setErrormsg("建档失败,保存异常"); + return br; + + } + + //加入产筛 + patientsService.validata(p); + + if (type == ServiceObjEnums.YUNOBJ.getId()) { + //生成建档短信 + createBuildSms(p); + } + + br.setErrorcode(ErrorCodeConstants.SUCCESS); + br.setErrormsg("成功"); + br.setData(p.getId()); + return br; + + } + + /** + * 创建孕妇建档短信 + */ + private void createBuildSms(Patients patient) { + + //判断医院是否启动和对应的服务项是否启用 + SmsConfigModel configModel = new SmsConfigModel(); + BaseResponse response = smsConfigFacade.hospitalIsStart(patient.getHospitalId(), configModel, SmsServiceEnums.FWKT.getId()); + if (response != null) { + return; + } + + SmsTemplateQuery query = new SmsTemplateQuery(); + query.setYn(YnEnums.YES.getId()); + query.setStatus(1); + query.setHospitalId(patient.getHospitalId()); + query.setServiceObj(ServiceObjEnums.YUNOBJ.getId()); + query.setSpecialDateType(SpecialDateEnums.JD.getId()); + + Integer serviceType = patient.getServiceType(); + Integer serviceStatus = patient.getServiceStatus(); + + List sendList = new ArrayList<>(); + + List temps = smsTemplateService.querySmsTemplates(query); + if (CollectionUtils.isNotEmpty(temps)) { + + for (SmsTemplateModel temp : temps) { + if (temp.getServiceType() == serviceType && temp.getServiceStatus() == serviceStatus) { + sendList.add(temp); + } else if (temp.getServiceType() == serviceType && temp.getServiceStatus() == serviceStatus) { + sendList.add(temp); + } else if (temp.getServiceStatus() == ServiceStatusEnums.ADD_ALL.getId()) { + if (serviceStatus == ServiceStatusEnums.ADD_OPEN.getId() || serviceStatus == ServiceStatusEnums.UNSUBSCRIBE.getId() + || serviceStatus == ServiceStatusEnums.ADD_OVERDUE.getId() || serviceStatus == ServiceStatusEnums.SUSPEND.getId()) { + sendList.add(temp); + } + } else if (temp.getServiceStatus() == ServiceStatusEnums.ALL_OPEN.getId()) { + if (serviceStatus == ServiceStatusEnums.STANDARD_OPEN.getId() || serviceStatus == ServiceStatusEnums.ADD_OPEN.getId()) { + sendList.add(temp); + } + } else if (temp.getServiceStatus() == ServiceStatusEnums.ALL_OVERDUE.getId()) { + if (serviceStatus == ServiceStatusEnums.STANDARD_OVERDUE.getId() || serviceStatus == ServiceStatusEnums.ADD_OVERDUE.getId()) { + sendList.add(temp); + } + } else if (temp.getServiceType() == ServiceTypeEnums.ALL_SERVICE.getId() && temp.getServiceStatus() == ServiceStatusEnums.ALL.getId()) { + sendList.add(temp); + } + } + + if (CollectionUtils.isNotEmpty(sendList)) { + + //短信前缀 + String messagePrefix = smsConfigFacade.getSmsPrefix(configModel, patient.getBookbuildingDoctor()); + for (SmsTemplateModel templateModel : sendList) { + if (templateModel != null && templateModel.getStatus() == 1) { + MessageListRequest smsList = new MessageListRequest(); + List messages = new ArrayList<>(); + MessageRequest mr = new MessageRequest(); + Date dueDate = DateUtil.addDay(patient.getLastMenses(), 7); + dueDate = DateUtil.addMonth(dueDate, 9); + String content = StringUtils.replaceEL(patient.getUsername(), dueDate, templateModel.getContent()); + + mr.setContent("【" + messagePrefix + "】" + content); + mr.setObjType(ServiceObjEnums.YUNOBJ.getId()); + mr.setPhone(patient.getPhone()); + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); + //短信商 + mr.setServiceType(SmsProviderEnums.YM.getId()); + mr.setTypeId(ProjectTypeEnums.YNXT.getId()); + mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); + mr.setSubTypeId(SmsServiceEnums.FWKT.getId()); + mr.setStatus(SmsStatusEnums.WFS.getId()); + mr.setExt1(patient.getHospitalId()); + mr.setExt2(templateModel.getId()); + mr.setExt3(patient.getId()); + messages.add(mr); + + if (CollectionUtils.isNotEmpty(messages)) { + smsList.setTypeId(ProjectTypeEnums.YNXT.getId()); + smsList.setMessages(messages); + //调用发送接口 + if (!syncDataService.savePostMsg(JsonUtil.obj2JsonString(smsList), messages.get(0).getExt1())) { + MessageCenterService.saveSmsCenter(smsList); + } + } + } + } + } + } + } + + + /** + * 判断对应服务是否启动 + */ + private boolean isStartService(Integer smsType, String serviceStr) { + if (StringUtils.isEmpty(serviceStr)) { + return false; + } + //消息服务启动 + List smsServices = JsonUtil.toList(serviceStr, Map.class); + + if (CollectionUtils.isNotEmpty(smsServices)) { + for (Map map : smsServices) { + String status = String.valueOf(map.get(String.valueOf(smsType))); + if ("true".equals(status)) { + return true; + } + } + } + return false; + } + + /** + * 更新孕妇信息 + * + * @param id + * @param yunRequest + */ + public BaseResponse updatePregnantById(String id, YunBookbuildingAddRequest yunRequest, Integer userId) { + + + BaseResponse br = new BaseResponse(); + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setType(1); + patientsQuery.setHospitalId(yunRequest.getHospitalId()); + patientsQuery.setBuildTypeEq(0); + patientsQuery.setDueStatus(0); + + if (yunRequest.getPregnantCertificateNum() != null) { + patientsQuery.setCardNo(yunRequest.getPregnantCertificateNum()); + //判断该身份证号码是否有孕妇建档 在该医院 + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + Patients pat = patients.get(0); + if (pat != null && !pat.getPhone().equals(yunRequest.getPregnantPhone())) { + if (StringUtils.isNotEmpty(yunRequest.getPregnantPhone())) { + patientsQuery.setCardNo(null); + patientsQuery.setPhone(yunRequest.getPregnantPhone()); + //判断该手机号码在 孕期内有没有建档 + patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); + br.setErrormsg("该手机号码已经建档"); + return br; + } + } + } + + if (pat != null && StringUtils.isNotEmpty(pat.getVcCardNo()) && !pat.getVcCardNo().equals(yunRequest.getVcCardNo())) { + + //就诊卡号判断 + if (StringUtils.isNotEmpty(yunRequest.getVcCardNo())) { + patientsQuery.setCardNo(null); + patientsQuery.setPhone(null); + patientsQuery.setVcCardNo(yunRequest.getVcCardNo()); + patientsQuery.setHospitalId(yunRequest.getHospitalId()); + patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + br.setErrorcode(ErrorCodeConstants.DATA_EXIST); + br.setErrormsg("该就诊卡号在该医院已经建档"); + return br; + } + } + } + } + } + + + Patients patient = getPatientsData(yunRequest); + patient.setModified(new Date()); // Integer type = ServiceObjEnums.YUNOBJ.getId(); // if (patient.getLastMenses() != null) @@ -481,1043 +436,975 @@ public class BookbuildingFacade { // patient.setType(type); - if (!StringUtils.isEmpty(yunRequest.getPid())) - { - PersonModel pmodel = new PersonModel(); - pmodel.setName(yunRequest.getPregnantName()); - pmodel.setBirth(DateUtil.parseYMD(yunRequest.getBirthday())); - pmodel.setPhone(yunRequest.getPregnantPhone()); - pmodel.setCardNo(yunRequest.getPregnantCertificateNum()); - pmodel.setYn(YnEnums.YES.getId()); - pmodel.setModified(new Date()); - personService.updatePerson(pmodel, yunRequest.getPid()); - } - patient.setId(id); - //加入产筛 - patientsService.validata(patient); - //如果当前是建档医院,那么需要修改其他非建档医院的数据 - if(autoMatchFacade.checkBStatus(userId)){ - patientsService.updateBaseData(patient); - } - - - PatientsQuery pQuery = new PatientsQuery(); - pQuery.setYn(YnEnums.YES.getId()); - pQuery.setId(id); - List list = yunBookbuildingService.queryPregnantWithQuery(pQuery); - if (CollectionUtils.isNotEmpty(list)) - { - Patients pat = list.get(0); - if (!(pat.getServiceStatus() == ServiceStatusEnums.STANDARD_OPEN.getId() || pat.getServiceStatus() == ServiceStatusEnums.ADD_OPEN.getId())) - { - - if (pat.getServiceType() == ServiceTypeEnums.STANDARD_SERVICE.getId()) - { - pat.setServiceStatus(ServiceStatusEnums.STANDARD_OPEN.getId()); - } - else if (pat.getServiceType() == ServiceTypeEnums.ADD_SERVICE.getId()) - { - pat.setServiceStatus(ServiceStatusEnums.ADD_OPEN.getId()); - } - - createBuildSms(pat); - } - } - - patient.setOperator(userId); - yunBookbuildingService.updatePregnant(patient, id); - - return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); - } - - /** - * 查询孕妇建档记录 - * @param bookbuildingQueryRequest - * @return - */ - public BaseListResponse queryPregnantBuildRecord(BookbuildingQueryRequest bookbuildingQueryRequest,Integer userId) { - List patients = new ArrayList<>(); - Map typeMap = new HashMap<>(); - PatientsQuery patientsQuery = new PatientsQuery(); - patientsQuery.setYn(YnEnums.YES.getId()); - patientsQuery.setBuildType(1); - //如果身份证号码不为空就以身份证号码查询 - if (!StringUtils.isEmpty(bookbuildingQueryRequest.getCardNo())) - { - patientsQuery.setCardNo(bookbuildingQueryRequest.getCardNo()); - patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery,"bookbuildingDate", Sort.Direction.DESC); - } - //否则用就诊卡号 查询到这个孕妇的身份证号码 再用身份证号码查询该孕妇的所有建档 包括产妇记录 - else if (!StringUtils.isEmpty(bookbuildingQueryRequest.getVcCardNo())) - { - String hospitalId = autoMatchFacade.getHospitalId(userId); - patientsQuery.setVcCardNo(bookbuildingQueryRequest.getVcCardNo()); - //区域模式 - if (!ErrorCodeConstants.RUN_MODE.equals(runType)) { - patientsQuery.setHospitalId(hospitalId); - } - - List patientsVc = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patientsVc)) - { - if (patientsVc.get(0) == null || StringUtils.isEmpty(patientsVc.get(0).getCardNo())) - { - patients = patientsVc; - } - else - { - patientsQuery.setHospitalId(null); - patientsQuery.setVcCardNo(null); - patientsQuery.setCardNo(patientsVc.get(0).getCardNo()); - patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery,"bookbuildingDate", Sort.Direction.DESC); - } - - } - // 如果为空,初次建档,根据就诊卡号从HIS库取患者信息 - else { - if ("2".equals(HIS_VERSION)) { - typeMap.put("hisPatient", hisServiceV2.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); - } else if ("3".equals(HIS_VERSION)) { - typeMap.put("hisPatient", qingLongXianHisService.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); - } else if ("5".equals(HIS_VERSION)) { - typeMap.put("hisPatient", fnfyHisService.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); - }else if ("4".equals(HIS_VERSION)) { - typeMap.put("hisPatient", qhdfyHisService.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); - } - } - } - - //历史建档记录 - List list = new ArrayList<>(); - List results = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(patients)) - { - for(Patients pat : patients) - { - if (pat != null) - { - BookbuildingRecordResult result = new BookbuildingRecordResult(); - if (StringUtils.isNotEmpty(pat.getHospitalId())) - { - Organization org = organizationService.getOrganization(Integer.valueOf(pat.getHospitalId())); - if (org != null) - { - result.setBookbuildHospital(org.getName()); - result.setHospitalId(String.valueOf(org.getId())); - } - } - result.setBookbuildDate(DateUtil.getyyyy_MM_dd(pat.getBookbuildingDate())); - result.setId(pat.getId()); - result.setType(pat.getType()); - result.setDueStatus(pat.getDueStatus()); - results.add(result); - } - } - } - - - - //证件类型 - List pcerteTypeResult = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CERTE_TYPE_ID); - typeMap.put("certeType", pcerteTypeResult); - - //国籍 - List countiryResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.COUNTRY_TYPE_ID); - typeMap.put("country", countiryResults); - - // 民族 - List nationResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.NATION_TYPE_ID); - typeMap.put("nation", nationResults); - - // 职业类别 - List professionTypeResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.PROFESSION_TYPE_ID); - typeMap.put("professionType", professionTypeResults); - - // 户籍类别 - List censusType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CENSUS_TYPE_ID); - typeMap.put("censusType", censusType); - - // 户籍类别 - List liveType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.LIVE_TYPE_ID); - typeMap.put("liveType", liveType); - - //服务类型 - List serviceType = ServiceTypeEnums.getServiceTypeList(); - typeMap.put("serviceType", serviceType); - - //服务状态 - List serviceStatus = ServiceStatusEnums.getServiceStatusList(); - typeMap.put("serviceStatus", serviceStatus); - - //孕妇体验类型 - List expYunEnums = ExpYunEnums.getExpYunEnums(); - typeMap.put("expYunEnums", expYunEnums); - - list.add(typeMap); - - - Map mapData = new HashMap<>(); - mapData.put("data",results); - mapData.put("initBuildDate", DateUtil.getyyyy_MM_dd(new Date())); - list.add(mapData); - - BaseListResponse listResponse = new BaseListResponse(); - listResponse.setData(list); - listResponse.setErrorcode(ErrorCodeConstants.SUCCESS); - listResponse.setErrormsg("成功"); - return listResponse; - } - - - - - /** - * 准备修改和添加的孕妇建档数据 - * @param yunRequest - * @return - */ - private Patients getPatientsData(YunBookbuildingAddRequest yunRequest) - { - Patients patient = new Patients(); - patient.setUsername(yunRequest.getPregnantName()); - - patient.setPcerteTypeId(yunRequest.getPregnantCertificateTypeId()); - - patient.setCardNo(yunRequest.getPregnantCertificateNum()); - - patient.setPcountryId(yunRequest.getPregnantCountryId()); - patient.setPnationId(yunRequest.getPregnantNationId()); - patient.setBirth(DateUtil.parseYMD(yunRequest.getBirthday())); - - patient.setPcensusTypeId(yunRequest.getPregnantCensusTypeId()); - - patient.setPliveTypeId(yunRequest.getPregnantLiveTypeId()); - - patient.setPprofessionTypeId(yunRequest.getPregnantProfessionTypeId()); - - patient.setPhone(yunRequest.getPregnantPhone()); - - patient.setPworkUnit(yunRequest.getPregnantWorkUnit()); - patient.setPlevelTypeId(yunRequest.getPregnantLevelTypeId()); - - //孕妇居住地 - patient.setAddressRegister(yunRequest.getPregnantCensusAddr()); - patient.setProvinceRegisterId(yunRequest.getPregnantCensusProvinceId()); - patient.setCityRegisterId(yunRequest.getPregnantCensusCityId()); - patient.setAreaRegisterId(yunRequest.getPregnantCensusAreaId()); - patient.setStreetRegisterId(yunRequest.getPregnantCensusStreetId()); - - //孕妇户籍地址 - patient.setAddress(yunRequest.getPregnantLiveAddr()); - patient.setProvinceId(yunRequest.getPregnantLiveProvinceId()); - patient.setCityId(yunRequest.getPregnantLiveCityId()); - patient.setAreaId(yunRequest.getPregnantLiveAreaId()); - patient.setStreetId(yunRequest.getPregnantLiveStreetId()); - - //孕妇产后修养地 - patient.setAddressPostRest(yunRequest.getChildbirthAddr()); - patient.setProvincePostRestId(yunRequest.getChildbirthProvinceId()); - patient.setCityPostRestId(yunRequest.getChildbirthCityId()); - patient.setAreaPostRestId(yunRequest.getChildbirthAreaId()); - patient.setStreetPostRestId(yunRequest.getChildbirthStreetId()); - - //丈夫信息 - patient.setHusbandName(yunRequest.getHusbandName()); - patient.setHcertificateTypeId(yunRequest.getHusbandCertificateTypeId()); - - if (StringUtils.isNotEmpty(yunRequest.getHusbandCertificateTypeId()) && StringUtils.isNotEmpty(yunRequest.getHusbandCertificateNum())) - { - BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); - basicConfigQuery.setId(yunRequest.getHusbandCertificateTypeId()); - basicConfigQuery.setYn(YnEnums.YES.getId()); - List data = basicConfigService.queryBasicConfig(basicConfigQuery); - if (CollectionUtils.isNotEmpty(data)) { - //身份证类型得到丈夫的生日 必须为身份证类型 - if ("SFZ".endsWith(data.get(0).getCode())) - { - String cardNo = yunRequest.getHusbandCertificateNum(); - Date birth = StringUtils.getBirthDay(cardNo); - patient.setHusbandBirth(birth); - } - } - } - - patient.setHcertificateNum(yunRequest.getHusbandCertificateNum()); - patient.setHusbandPhone(yunRequest.getHusbandPhone()); - patient.setHcountryId(yunRequest.getHusbandCountryId()); - patient.setHnationId(yunRequest.getHusbandNationId()); - patient.setHprofessionTypeId(yunRequest.getHusbandProfessionTypeId()); - patient.setHworkUnit(yunRequest.getHusbandWorkUnit()); - patient.setHaddressRegister(yunRequest.getHusbandAddressRegister()); - patient.setHprovinceRegisterId(yunRequest.getHusbandProvinceRegisterId()); - patient.setHcityRegisterId(yunRequest.getHusbandCityRegisterId()); - patient.setHareaRegisterId(yunRequest.getHusbandAreaRegisterId()); - patient.setHstreetRegisterId(yunRequest.getHusbandStreetRegisterId()); - patient.setHlevelTypeId(yunRequest.getHusbandLevelTypeId()); - - patient.setServiceStatus(yunRequest.getServiceStatus()); - - if (yunRequest.getExpType() != null) - { - if (yunRequest.getExpType() == ExpYunEnums.SGY.getId()) - { - Date vipEndTime = DateUtil.addMonth(DateUtil.parseYMD(yunRequest.getBookbuildingDate()),3); - Date dueDate = DateUtil.parseYMD(yunRequest.getDueDate()); - if (vipEndTime.getTime() > dueDate.getTime()) - { - vipEndTime = dueDate; - } - patient.setVipEndTime(vipEndTime); - } - else - { - Date vipEndTime = DateUtil.parseYMD(yunRequest.getDueDate()); - patient.setVipEndTime(vipEndTime); - } - patient.setExpType(yunRequest.getExpType()); - } - - - //patient.setVipEndTime(DateUtil.parseYMD(yunRequest.getVipEndTime())); - patient.setExpVip(yunRequest.getExpVip()); - patient.setMremark(yunRequest.getMremark()); - - patient.setLastMenses(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod())); - patient.setDueDate(DateUtil.parseYMD(yunRequest.getDueDate())); - patient.setFileCode(yunRequest.getFileCode()); - patient.setBookbuildingDoctor(yunRequest.getBookbuildingDoctor()); - patient.setBookbuildingDate(DateUtil.parseYMD(yunRequest.getBookbuildingDate())); - patient.setServiceType(yunRequest.getServiceType()); - patient.setVcCardNo(yunRequest.getVcCardNo()); - patient.setHospitalId(yunRequest.getHospitalId()); - patient.setYn(YnEnums.YES.getId()); - - return patient; - } - - /** - * 查询孕妇建档详细 - * @param id - * @return - */ - public BaseObjectResponse queryPregnantBuildById(String id) { - - PatientsQuery patientsQuery = new PatientsQuery(); - patientsQuery.setId(id); - patientsQuery.setYn(YnEnums.YES.getId()); - PregnantInfoResult result = new PregnantInfoResult(); - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (patients != null && patients.size() > 0) - { - Patients p = patients.get(0); - result = getResult(p); - } - - BaseObjectResponse objectResponse = new BaseObjectResponse(); - objectResponse.setData(result); - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); - objectResponse.setErrormsg("成功"); - return objectResponse; - } - - - private PregnantInfoResult getResult(Patients p) - { - PregnantInfoResult result = new PregnantInfoResult(); - result.setId(p.getId()); - /**********孕妇基本信息***************/ - result.setPregnantName(p.getUsername()); - result.setPregnantCertificateTypeId(p.getPcerteTypeId()); - result.setPregnantCertificateNum(p.getCardNo()); - result.setPregnantCountryId(p.getPcountryId()); - result.setPregnantNationId(p.getPnationId()); - result.setBirthday(DateUtil.getyyyy_MM_dd(p.getBirth())); - result.setPregnantCensusTypeId(p.getPcensusTypeId()); - result.setPregnantLiveTypeId(p.getPliveTypeId()); - result.setPregnantProfessionTypeId(p.getPprofessionTypeId()); - result.setPregnantLevelTypeId(p.getPlevelTypeId()); - - /**********孕妇联系方式***************/ - result.setPregnantPhone(p.getPhone()); - result.setPregnantWorkUnit(p.getPworkUnit()); - - result.setPregnantCensusProvinceId(p.getProvinceRegisterId()); - result.setPregnantCensusCityId(p.getCityRegisterId()); - result.setPregnantCensusAreaId(p.getAreaRegisterId()); - result.setPregnantCensusStreetId(p.getStreetRegisterId()); - result.setPregnantCensusAddr(p.getAddressRegister()); - - result.setPregnantLiveProvinceId(p.getProvinceId()); - result.setPregnantLiveCityId(p.getCityId()); - result.setPregnantLiveAreaId(p.getAreaId()); - result.setPregnantLiveStreetId(p.getStreetId()); - result.setPregnantLiveAddr(p.getAddress()); - - - result.setChildbirthAddr(p.getAddressPostRest()); - result.setChildbirthProvinceId(p.getProvincePostRestId()); - result.setChildbirthCityId(p.getCityPostRestId()); - result.setChildbirthAreaId(p.getAreaPostRestId()); - result.setChildbirthStreetId(p.getStreetPostRestId()); - - /****************丈夫信息**************/ - result.setHusbandName(p.getHusbandName()); - result.setHusbandPhone(p.getHusbandPhone()); - - result.setHusbandCertificateTypeId(p.getHcertificateTypeId()); - result.setHusbandCertificateNum(p.getHcertificateNum()); - result.setHusbandCountryId(p.getHcountryId()); - result.setHusbandNationId(p.getHnationId()); - result.setHusbandProfessionTypeId(p.getHprofessionTypeId()); - result.setHusbandWorkUnit(p.getHworkUnit()); - result.setHusbandLevelTypeId(p.getHlevelTypeId()); - - result.setHusbandAddressRegister(p.getHaddressRegister()); - result.setHusbandProvinceRegisterId(p.getHprovinceRegisterId()); - result.setHusbandCityRegisterId(p.getHcityRegisterId()); - result.setHusbandAreaRegisterId(p.getHareaRegisterId()); - result.setHusbandStreetRegisterId(p.getHstreetRegisterId()); - - result.setServiceStatus(p.getServiceStatus() == null ? "" : String.valueOf(p.getServiceStatus())); - result.setVipEndTime(DateUtil.getyyyy_MM_dd(p.getVipEndTime())); - result.setExpVip(p.getExpVip()); - result.setMremark(p.getMremark()); - - - //院内信息 - result.setLastMenstrualPeriod(DateUtil.getyyyy_MM_dd(p.getLastMenses())); - result.setDueDate(DateUtil.getyyyy_MM_dd(p.getDueDate())); - result.setFileCode(p.getFileCode()); - result.setVcCardNo(p.getVcCardNo()); - - if (StringUtils.isNotEmpty(p.getBookbuildingDoctor())) - { - Users users = usersService.getUsers(Integer.parseInt(p.getBookbuildingDoctor())); - if (users != null) - { - Map doctorObj = new HashMap<>(); - doctorObj.put("id",p.getBookbuildingDoctor()); - doctorObj.put("name",users.getName()); - result.setBookbuildingDoctor(doctorObj); - } - } - - result.setBookbuildingDate(DateUtil.getyyyy_MM_dd(p.getBookbuildingDate())); - result.setServiceType(p.getServiceType() == null ? "" : String.valueOf(p.getServiceType())); - - result.setExpType(p.getExpType()); - - result.setPid(p.getPid()); - result.setDueStatus(p.getDueStatus()); - return result; - } - - /** - * 孕妇建档页面基础数据 - * @return - */ - public BaseObjectResponse getYunBuildBaseConfig() { - Map typeMap = new HashMap<>(); - - //证件类型 - List pcerteTypeResult = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CERTE_TYPE_ID); - typeMap.put("certeType", pcerteTypeResult); - - //国籍 - List countiryResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.COUNTRY_TYPE_ID); - typeMap.put("country", countiryResults); - - // 民族 - List nationResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.NATION_TYPE_ID); - typeMap.put("nation", nationResults); - - // 职业类别 - List professionTypeResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.PROFESSION_TYPE_ID); - typeMap.put("professionType", professionTypeResults); - - // 户籍类别 - List censusType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CENSUS_TYPE_ID); - typeMap.put("censusType", censusType); - - // 户籍类别 - List liveType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.LIVE_TYPE_ID); - typeMap.put("liveType", liveType); - - //服务类型 - List serviceType = ServiceTypeEnums.getServiceTypeList(); - typeMap.put("serviceType", serviceType); - - //服务状态 - List serviceStatus = ServiceStatusEnums.getServiceStatusList(); - typeMap.put("serviceStatus", serviceStatus); - - //孕妇体验类型 - List expYunEnums = ExpYunEnums.getExpYunEnums(); - typeMap.put("expYunEnums", expYunEnums); - - - BaseObjectResponse objectResponse = new BaseObjectResponse(); - objectResponse.setData(typeMap); - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); - objectResponse.setErrormsg("成功"); - return objectResponse; - } - - /** - * 删除孕妇建档 - * @param id - * @return - */ - public BaseResponse deletePregnantById(String id,Integer userId) { - AntExChuQuery antExChuQuery = new AntExChuQuery(); - antExChuQuery.setParentId(id); - antExChuQuery.setYn(YnEnums.YES.getId()); - //获取初诊记录 - List antExChulist = antenatalExaminationService.queryAntExChu(antExChuQuery); - String hospital = autoMatchFacade.getHospitalId(userId); - Patients patients = yunBookbuildingService.findOneById(id); + if (!StringUtils.isEmpty(yunRequest.getPid())) { + PersonModel pmodel = new PersonModel(); + pmodel.setName(yunRequest.getPregnantName()); + pmodel.setBirth(DateUtil.parseYMD(yunRequest.getBirthday())); + pmodel.setPhone(yunRequest.getPregnantPhone()); + pmodel.setCardNo(yunRequest.getPregnantCertificateNum()); + pmodel.setYn(YnEnums.YES.getId()); + pmodel.setModified(new Date()); + personService.updatePerson(pmodel, yunRequest.getPid()); + } + patient.setId(id); + //加入产筛 + patientsService.validata(patient); + //如果当前是建档医院,那么需要修改其他非建档医院的数据 + if (autoMatchFacade.checkBStatus(userId)) { + patientsService.updateBaseData(patient); + } + + + PatientsQuery pQuery = new PatientsQuery(); + pQuery.setYn(YnEnums.YES.getId()); + pQuery.setId(id); + List list = yunBookbuildingService.queryPregnantWithQuery(pQuery); + if (CollectionUtils.isNotEmpty(list)) { + Patients pat = list.get(0); + if (!(pat.getServiceStatus() == ServiceStatusEnums.STANDARD_OPEN.getId() || pat.getServiceStatus() == ServiceStatusEnums.ADD_OPEN.getId())) { + + if (pat.getServiceType() == ServiceTypeEnums.STANDARD_SERVICE.getId()) { + pat.setServiceStatus(ServiceStatusEnums.STANDARD_OPEN.getId()); + } else if (pat.getServiceType() == ServiceTypeEnums.ADD_SERVICE.getId()) { + pat.setServiceStatus(ServiceStatusEnums.ADD_OPEN.getId()); + } + + createBuildSms(pat); + } + } + + patient.setOperator(userId); + yunBookbuildingService.updatePregnant(patient, id); + + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + } + + /** + * 查询孕妇建档记录 + * + * @param bookbuildingQueryRequest + * @return + */ + public BaseListResponse queryPregnantBuildRecord(BookbuildingQueryRequest bookbuildingQueryRequest, Integer userId) { + List patients = new ArrayList<>(); + Map typeMap = new HashMap<>(); + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setBuildType(1); + //如果身份证号码不为空就以身份证号码查询 + if (!StringUtils.isEmpty(bookbuildingQueryRequest.getCardNo())) { + patientsQuery.setCardNo(bookbuildingQueryRequest.getCardNo()); + patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery, "bookbuildingDate", Sort.Direction.DESC); + } + //否则用就诊卡号 查询到这个孕妇的身份证号码 再用身份证号码查询该孕妇的所有建档 包括产妇记录 + else if (!StringUtils.isEmpty(bookbuildingQueryRequest.getVcCardNo())) { + + patientsQuery.setVcCardNo(bookbuildingQueryRequest.getVcCardNo()); + + //区域模式 + patientsQuery.setHospitalList(groupsFacade.findGroupHospital(userId)); + + List patientsVc = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patientsVc)) { + if (patientsVc.get(0) == null || StringUtils.isEmpty(patientsVc.get(0).getCardNo())) { + patients = patientsVc; + } else { + patientsQuery.setHospitalId(null); + patientsQuery.setVcCardNo(null); + patientsQuery.setCardNo(patientsVc.get(0).getCardNo()); + patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery, "bookbuildingDate", Sort.Direction.DESC); + } + + } + // 如果为空,初次建档,根据就诊卡号从HIS库取患者信息 + else { + if ("2".equals(HIS_VERSION)) { + typeMap.put("hisPatient", hisServiceV2.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); + } else if ("3".equals(HIS_VERSION)) { + typeMap.put("hisPatient", qingLongXianHisService.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); + } else if ("5".equals(HIS_VERSION)) { + typeMap.put("hisPatient", fnfyHisService.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); + } else if ("4".equals(HIS_VERSION)) { + typeMap.put("hisPatient", qhdfyHisService.getPatientInfoList(bookbuildingQueryRequest.getVcCardNo())); + } + } + } + + //历史建档记录 + List list = new ArrayList<>(); + List results = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(patients)) { + for (Patients pat : patients) { + if (pat != null) { + BookbuildingRecordResult result = new BookbuildingRecordResult(); + if (StringUtils.isNotEmpty(pat.getHospitalId())) { + Organization org = organizationService.getOrganization(Integer.valueOf(pat.getHospitalId())); + if (org != null) { + result.setBookbuildHospital(org.getName()); + result.setHospitalId(String.valueOf(org.getId())); + } + } + result.setBookbuildDate(DateUtil.getyyyy_MM_dd(pat.getBookbuildingDate())); + result.setId(pat.getId()); + result.setType(pat.getType()); + result.setDueStatus(pat.getDueStatus()); + results.add(result); + } + } + } + + + //证件类型 + List pcerteTypeResult = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CERTE_TYPE_ID); + typeMap.put("certeType", pcerteTypeResult); + + //国籍 + List countiryResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.COUNTRY_TYPE_ID); + typeMap.put("country", countiryResults); + + // 民族 + List nationResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.NATION_TYPE_ID); + typeMap.put("nation", nationResults); + + // 职业类别 + List professionTypeResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.PROFESSION_TYPE_ID); + typeMap.put("professionType", professionTypeResults); + + // 户籍类别 + List censusType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CENSUS_TYPE_ID); + typeMap.put("censusType", censusType); + + // 户籍类别 + List liveType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.LIVE_TYPE_ID); + typeMap.put("liveType", liveType); + + //服务类型 + List serviceType = ServiceTypeEnums.getServiceTypeList(); + typeMap.put("serviceType", serviceType); + + //服务状态 + List serviceStatus = ServiceStatusEnums.getServiceStatusList(); + typeMap.put("serviceStatus", serviceStatus); + + //孕妇体验类型 + List expYunEnums = ExpYunEnums.getExpYunEnums(); + typeMap.put("expYunEnums", expYunEnums); + + list.add(typeMap); + + + Map mapData = new HashMap<>(); + mapData.put("data", results); + mapData.put("initBuildDate", DateUtil.getyyyy_MM_dd(new Date())); + list.add(mapData); + + BaseListResponse listResponse = new BaseListResponse(); + listResponse.setData(list); + listResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + listResponse.setErrormsg("成功"); + return listResponse; + } + + + /** + * 准备修改和添加的孕妇建档数据 + * + * @param yunRequest + * @return + */ + private Patients getPatientsData(YunBookbuildingAddRequest yunRequest) { + Patients patient = new Patients(); + patient.setUsername(yunRequest.getPregnantName()); + + patient.setPcerteTypeId(yunRequest.getPregnantCertificateTypeId()); + + patient.setCardNo(yunRequest.getPregnantCertificateNum()); + + patient.setPcountryId(yunRequest.getPregnantCountryId()); + patient.setPnationId(yunRequest.getPregnantNationId()); + patient.setBirth(DateUtil.parseYMD(yunRequest.getBirthday())); + + patient.setPcensusTypeId(yunRequest.getPregnantCensusTypeId()); + + patient.setPliveTypeId(yunRequest.getPregnantLiveTypeId()); + + patient.setPprofessionTypeId(yunRequest.getPregnantProfessionTypeId()); + + patient.setPhone(yunRequest.getPregnantPhone()); + + patient.setPworkUnit(yunRequest.getPregnantWorkUnit()); + patient.setPlevelTypeId(yunRequest.getPregnantLevelTypeId()); + + //孕妇居住地 + patient.setAddressRegister(yunRequest.getPregnantCensusAddr()); + patient.setProvinceRegisterId(yunRequest.getPregnantCensusProvinceId()); + patient.setCityRegisterId(yunRequest.getPregnantCensusCityId()); + patient.setAreaRegisterId(yunRequest.getPregnantCensusAreaId()); + patient.setStreetRegisterId(yunRequest.getPregnantCensusStreetId()); + + //孕妇户籍地址 + patient.setAddress(yunRequest.getPregnantLiveAddr()); + patient.setProvinceId(yunRequest.getPregnantLiveProvinceId()); + patient.setCityId(yunRequest.getPregnantLiveCityId()); + patient.setAreaId(yunRequest.getPregnantLiveAreaId()); + patient.setStreetId(yunRequest.getPregnantLiveStreetId()); + + //孕妇产后修养地 + patient.setAddressPostRest(yunRequest.getChildbirthAddr()); + patient.setProvincePostRestId(yunRequest.getChildbirthProvinceId()); + patient.setCityPostRestId(yunRequest.getChildbirthCityId()); + patient.setAreaPostRestId(yunRequest.getChildbirthAreaId()); + patient.setStreetPostRestId(yunRequest.getChildbirthStreetId()); + + //丈夫信息 + patient.setHusbandName(yunRequest.getHusbandName()); + patient.setHcertificateTypeId(yunRequest.getHusbandCertificateTypeId()); + + if (StringUtils.isNotEmpty(yunRequest.getHusbandCertificateTypeId()) && StringUtils.isNotEmpty(yunRequest.getHusbandCertificateNum())) { + BasicConfigQuery basicConfigQuery = new BasicConfigQuery(); + basicConfigQuery.setId(yunRequest.getHusbandCertificateTypeId()); + basicConfigQuery.setYn(YnEnums.YES.getId()); + List data = basicConfigService.queryBasicConfig(basicConfigQuery); + if (CollectionUtils.isNotEmpty(data)) { + //身份证类型得到丈夫的生日 必须为身份证类型 + if ("SFZ".endsWith(data.get(0).getCode())) { + String cardNo = yunRequest.getHusbandCertificateNum(); + Date birth = StringUtils.getBirthDay(cardNo); + patient.setHusbandBirth(birth); + } + } + } + + patient.setHcertificateNum(yunRequest.getHusbandCertificateNum()); + patient.setHusbandPhone(yunRequest.getHusbandPhone()); + patient.setHcountryId(yunRequest.getHusbandCountryId()); + patient.setHnationId(yunRequest.getHusbandNationId()); + patient.setHprofessionTypeId(yunRequest.getHusbandProfessionTypeId()); + patient.setHworkUnit(yunRequest.getHusbandWorkUnit()); + patient.setHaddressRegister(yunRequest.getHusbandAddressRegister()); + patient.setHprovinceRegisterId(yunRequest.getHusbandProvinceRegisterId()); + patient.setHcityRegisterId(yunRequest.getHusbandCityRegisterId()); + patient.setHareaRegisterId(yunRequest.getHusbandAreaRegisterId()); + patient.setHstreetRegisterId(yunRequest.getHusbandStreetRegisterId()); + patient.setHlevelTypeId(yunRequest.getHusbandLevelTypeId()); + + patient.setServiceStatus(yunRequest.getServiceStatus()); + + if (yunRequest.getExpType() != null) { + if (yunRequest.getExpType() == ExpYunEnums.SGY.getId()) { + Date vipEndTime = DateUtil.addMonth(DateUtil.parseYMD(yunRequest.getBookbuildingDate()), 3); + Date dueDate = DateUtil.parseYMD(yunRequest.getDueDate()); + if (vipEndTime.getTime() > dueDate.getTime()) { + vipEndTime = dueDate; + } + patient.setVipEndTime(vipEndTime); + } else { + Date vipEndTime = DateUtil.parseYMD(yunRequest.getDueDate()); + patient.setVipEndTime(vipEndTime); + } + patient.setExpType(yunRequest.getExpType()); + } + + + //patient.setVipEndTime(DateUtil.parseYMD(yunRequest.getVipEndTime())); + patient.setExpVip(yunRequest.getExpVip()); + patient.setMremark(yunRequest.getMremark()); + + patient.setLastMenses(DateUtil.parseYMD(yunRequest.getLastMenstrualPeriod())); + patient.setDueDate(DateUtil.parseYMD(yunRequest.getDueDate())); + patient.setFileCode(yunRequest.getFileCode()); + patient.setBookbuildingDoctor(yunRequest.getBookbuildingDoctor()); + patient.setBookbuildingDate(DateUtil.parseYMD(yunRequest.getBookbuildingDate())); + patient.setServiceType(yunRequest.getServiceType()); + patient.setVcCardNo(yunRequest.getVcCardNo()); + patient.setHospitalId(yunRequest.getHospitalId()); + patient.setYn(YnEnums.YES.getId()); + + return patient; + } + + /** + * 查询孕妇建档详细 + * + * @param id + * @return + */ + public BaseObjectResponse queryPregnantBuildById(String id) { + + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setId(id); + patientsQuery.setYn(YnEnums.YES.getId()); + PregnantInfoResult result = new PregnantInfoResult(); + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (patients != null && patients.size() > 0) { + Patients p = patients.get(0); + result = getResult(p); + } + + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setData(result); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } + + + private PregnantInfoResult getResult(Patients p) { + PregnantInfoResult result = new PregnantInfoResult(); + result.setId(p.getId()); + /**********孕妇基本信息***************/ + result.setPregnantName(p.getUsername()); + result.setPregnantCertificateTypeId(p.getPcerteTypeId()); + result.setPregnantCertificateNum(p.getCardNo()); + result.setPregnantCountryId(p.getPcountryId()); + result.setPregnantNationId(p.getPnationId()); + result.setBirthday(DateUtil.getyyyy_MM_dd(p.getBirth())); + result.setPregnantCensusTypeId(p.getPcensusTypeId()); + result.setPregnantLiveTypeId(p.getPliveTypeId()); + result.setPregnantProfessionTypeId(p.getPprofessionTypeId()); + result.setPregnantLevelTypeId(p.getPlevelTypeId()); + + /**********孕妇联系方式***************/ + result.setPregnantPhone(p.getPhone()); + result.setPregnantWorkUnit(p.getPworkUnit()); + + result.setPregnantCensusProvinceId(p.getProvinceRegisterId()); + result.setPregnantCensusCityId(p.getCityRegisterId()); + result.setPregnantCensusAreaId(p.getAreaRegisterId()); + result.setPregnantCensusStreetId(p.getStreetRegisterId()); + result.setPregnantCensusAddr(p.getAddressRegister()); + + result.setPregnantLiveProvinceId(p.getProvinceId()); + result.setPregnantLiveCityId(p.getCityId()); + result.setPregnantLiveAreaId(p.getAreaId()); + result.setPregnantLiveStreetId(p.getStreetId()); + result.setPregnantLiveAddr(p.getAddress()); + + + result.setChildbirthAddr(p.getAddressPostRest()); + result.setChildbirthProvinceId(p.getProvincePostRestId()); + result.setChildbirthCityId(p.getCityPostRestId()); + result.setChildbirthAreaId(p.getAreaPostRestId()); + result.setChildbirthStreetId(p.getStreetPostRestId()); + + /****************丈夫信息**************/ + result.setHusbandName(p.getHusbandName()); + result.setHusbandPhone(p.getHusbandPhone()); + + result.setHusbandCertificateTypeId(p.getHcertificateTypeId()); + result.setHusbandCertificateNum(p.getHcertificateNum()); + result.setHusbandCountryId(p.getHcountryId()); + result.setHusbandNationId(p.getHnationId()); + result.setHusbandProfessionTypeId(p.getHprofessionTypeId()); + result.setHusbandWorkUnit(p.getHworkUnit()); + result.setHusbandLevelTypeId(p.getHlevelTypeId()); + + result.setHusbandAddressRegister(p.getHaddressRegister()); + result.setHusbandProvinceRegisterId(p.getHprovinceRegisterId()); + result.setHusbandCityRegisterId(p.getHcityRegisterId()); + result.setHusbandAreaRegisterId(p.getHareaRegisterId()); + result.setHusbandStreetRegisterId(p.getHstreetRegisterId()); + + result.setServiceStatus(p.getServiceStatus() == null ? "" : String.valueOf(p.getServiceStatus())); + result.setVipEndTime(DateUtil.getyyyy_MM_dd(p.getVipEndTime())); + result.setExpVip(p.getExpVip()); + result.setMremark(p.getMremark()); + + + //院内信息 + result.setLastMenstrualPeriod(DateUtil.getyyyy_MM_dd(p.getLastMenses())); + result.setDueDate(DateUtil.getyyyy_MM_dd(p.getDueDate())); + result.setFileCode(p.getFileCode()); + result.setVcCardNo(p.getVcCardNo()); + + if (StringUtils.isNotEmpty(p.getBookbuildingDoctor())) { + Users users = usersService.getUsers(Integer.parseInt(p.getBookbuildingDoctor())); + if (users != null) { + Map doctorObj = new HashMap<>(); + doctorObj.put("id", p.getBookbuildingDoctor()); + doctorObj.put("name", users.getName()); + result.setBookbuildingDoctor(doctorObj); + } + } + + result.setBookbuildingDate(DateUtil.getyyyy_MM_dd(p.getBookbuildingDate())); + result.setServiceType(p.getServiceType() == null ? "" : String.valueOf(p.getServiceType())); + + result.setExpType(p.getExpType()); + + result.setPid(p.getPid()); + result.setDueStatus(p.getDueStatus()); + return result; + } + + /** + * 孕妇建档页面基础数据 + * + * @return + */ + public BaseObjectResponse getYunBuildBaseConfig() { + Map typeMap = new HashMap<>(); + + //证件类型 + List pcerteTypeResult = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CERTE_TYPE_ID); + typeMap.put("certeType", pcerteTypeResult); + + //国籍 + List countiryResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.COUNTRY_TYPE_ID); + typeMap.put("country", countiryResults); + + // 民族 + List nationResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.NATION_TYPE_ID); + typeMap.put("nation", nationResults); + + // 职业类别 + List professionTypeResults = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.PROFESSION_TYPE_ID); + typeMap.put("professionType", professionTypeResults); + + // 户籍类别 + List censusType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.CENSUS_TYPE_ID); + typeMap.put("censusType", censusType); + + // 户籍类别 + List liveType = basicConfigFacade.getBaseicConfigByParentId(SystemConfig.LIVE_TYPE_ID); + typeMap.put("liveType", liveType); + + //服务类型 + List serviceType = ServiceTypeEnums.getServiceTypeList(); + typeMap.put("serviceType", serviceType); + + //服务状态 + List serviceStatus = ServiceStatusEnums.getServiceStatusList(); + typeMap.put("serviceStatus", serviceStatus); + + //孕妇体验类型 + List expYunEnums = ExpYunEnums.getExpYunEnums(); + typeMap.put("expYunEnums", expYunEnums); + + + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setData(typeMap); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } + + /** + * 删除孕妇建档 + * + * @param id + * @return + */ + public BaseResponse deletePregnantById(String id, Integer userId) { + AntExChuQuery antExChuQuery = new AntExChuQuery(); + antExChuQuery.setParentId(id); + antExChuQuery.setYn(YnEnums.YES.getId()); + //获取初诊记录 + List antExChulist = antenatalExaminationService.queryAntExChu(antExChuQuery); + String hospital = autoMatchFacade.getHospitalId(userId); + Patients patients = yunBookbuildingService.findOneById(id); // if (CollectionUtils.isNotEmpty(antExChulist)) - if(!deleteProcessHandler.deleteBookBuild(patients.getPid(),patients.getBookbuildingDate(),hospital)) - { - return new BaseResponse().setErrorcode(ErrorCodeConstants.DONT_DELETE).setErrormsg("孕妇存在检查记录,不能删除建档"); - } - yunBookbuildingService.deletePregnantById(id); - //删除建档需要删除产筛数据 - SieveQuery sieveQuery=new SieveQuery(); - sieveQuery.setYn(YnEnums.YES.getId()); - sieveQuery.setParentId(id); - sieveService.deleteById(sieveQuery); - return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); - } - - /** - * 查询孕妇基本信息 通过就诊卡号或者身份证 - * @param cardNo - * @param vcCardNo - * @return - */ - public BaseObjectResponse queryYunBuildInfo(String cardNo, String vcCardNo,Integer userId) { - Patients pat = null; - PatientsQuery patientsQuery = new PatientsQuery(); - patientsQuery.setYn(YnEnums.YES.getId()); - if (StringUtils.isNotEmpty(cardNo)) - { - patientsQuery.setCardNo(cardNo); - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) - { - pat = patients.get(0); - } - } - - String hospitalId = ""; - //得到当前登录的医院id - if (userId != null) - { - Users dbuser = usersService.getUsers(userId); - if (dbuser != null) { - hospitalId = String.valueOf(dbuser.getOrgId()); - } - } - - if (StringUtils.isNotEmpty(vcCardNo) && StringUtils.isNotEmpty(hospitalId)) - { - patientsQuery.setVcCardNo(vcCardNo); - patientsQuery.setHospitalId(hospitalId); - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(patients)) - { - Patients vcCardNoPat = patients.get(0); - patientsQuery.setHospitalId(null); - patientsQuery.setVcCardNo(null); - patientsQuery.setCardNo(vcCardNoPat.getCardNo()); - List cardNoPat = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (CollectionUtils.isNotEmpty(cardNoPat)) - { - pat = cardNoPat.get(0); - } - } - } - BaseObjectResponse objectResponse = new BaseObjectResponse(); - if (pat == null) - { - objectResponse.setData(""); - } - else - { - objectResponse.setData(getResult(pat)); - } - - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); - objectResponse.setErrormsg("成功"); - return objectResponse; - } - - public BaseObjectResponse queryHospitals(String keyWord, Integer page, Integer limit) { - OrganizationQuery organizationQuery = new OrganizationQuery(); - if(null != page && limit != page) { - organizationQuery.setNeed("true"); - organizationQuery.setPage(page); - organizationQuery.setLimit(limit); - organizationQuery.setSort("modified desc"); - } - - organizationQuery.setYn(YnEnums.YES.getId()); - organizationQuery.setKeyword(keyWord); - - - List> mapList = new ArrayList<>(); - List orgs = organizationService.queryHospitals(organizationQuery); - if (CollectionUtils.isNotEmpty(orgs)) - { - for(Organization org : orgs) - { - Map map = new HashMap<>(); - map.put("id",org.getId()+""); - map.put("name", org.getName()); - mapList.add(map); - } - } - - BaseObjectResponse objectResponse = new BaseObjectResponse(); - objectResponse.setData(mapList); - - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); - objectResponse.setErrormsg("成功"); - return objectResponse; - } - - public BaseListResponse queryChanJianReport(Integer userId, String exDateStart, - String exDateEnd, - String name, - Integer weekStarts, - Integer weekEnds, - String hbsag, - String hbeag, - String hbeab, - String hbcab, - String syphilis, - String hiv, - String hcv, - String doctorNo, - Integer page, - Integer limit) { - - String hospitalId = autoMatchFacade.getHospitalId(userId); - - int start = 0; - int end = 1000; - if (page != null && limit != null) - { - start = (page -1) * limit+1; - end = page*limit; - } - String countSql =" SELECT count(*) as allCount "+ - "FROM ODS_F_AUXILIARY_EXAMI A\n" + - "INNER JOIN ODS_F_GRAVIDA_RECORD B ON A.RECORD_ID=B.RECORD_ID\n" + - "INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO AND C.VER_NO=2\n" + - "WHERE C.YCY_STSTEM_ID= '"+hospitalId +"'"; - - - String sql = "SELECT * FROM ( SELECT A.*, ROWNUM RN FROM ( SELECT A.EXAMINE_DATE,\n" + - " A.NAME,\n" + - " A.AGE,\n" + - " A.NOW_WEEKS,\n" + - " A.NOW_WEEKS_DAY, \n" + - " B.EDD_DATE,\n" + - " A.HBSAG,\n" + - " A.HBSAB,\n" + - " A.HBEAG,\n" + - " A.HBEAB,\n" + - " A.HBCAB,\n" + - " A.SYPHILIS,\n" + - " A.HIV,\n" + - " A.HCV,\n" + - " (CASE WHEN A.HIGH_RISK_GRADE IS NULL THEN '绿色预警' ELSE A.HIGH_RISK_GRADE END) AS HIGH_RISK_GRADE,\n" + - " (CASE WHEN A.HIGH_RISK_FACTOR IS NULL THEN '健康' ELSE A.HIGH_RISK_FACTOR END) AS HIGH_RISK_FACTOR,\n" + - " A.NEXT_EXAMINE_DATE,\n" + - " A.EXAMINE_HISTORY_NUM,\n" + - " A.DOCTOR_NAME,\n" + - " A.DOCTOR_NAME AS BOOKER,\n" + - " DECODE(B.IS_VIP_ID,1,'增值服务','标准服务') AS SERVICE_STATUS,\n" + - " A.SUGGESTION,\n" + - " B.TEL_NO,\n" + - " B.HOME_ADDR,\n" + - " B.STREET_VALLAGE_ID,\n" + - " B.STREET_VALLAGE,\n" + - " B.AREA_COUNTY_ID,\n" + - " B.AREA_COUNTY,\n" + - " B.CITY_ID,\n" + - " B.CITY,\n" + - " B.PROVINCE_ID,\n" + - " B.PROVINCE\n" + - " FROM ODS_F_AUXILIARY_EXAMI A " + - " INNER JOIN ODS_F_GRAVIDA_RECORD B ON A.RECORD_ID=B.RECORD_ID \n" + - " INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO AND C.VER_NO=2 \n" + - " WHERE C.YCY_STSTEM_ID= '"+hospitalId +"'"; - if (StringUtils.isNotEmpty(exDateStart)) - { - sql += " AND A.EXAMINE_DATE>= to_date('"+exDateStart+"','yyyy-MM-dd')"; - countSql += " AND A.EXAMINE_DATE>= to_date('"+exDateStart+"','yyyy-MM-dd')"; - } - if (StringUtils.isNotEmpty(exDateEnd)) - { - sql += " AND A.EXAMINE_DATE <= to_date('"+exDateEnd+"','yyyy-MM-dd')"; - countSql += " AND A.EXAMINE_DATE <= to_date('"+exDateEnd+"','yyyy-MM-dd')"; - } - - if (StringUtils.isNotEmpty(name)) - { - sql += " AND A.NAME LIKE '%"+name+"%'"; - countSql += " AND A.NAME LIKE '%"+name+"%'"; - } - - if (weekStarts != null) - { - sql += " AND A.NOW_WEEKS>= "+weekStarts; - countSql += " AND A.NOW_WEEKS>= "+weekStarts; - } - - if (weekEnds != null) - { - sql += " AND A.NOW_WEEKS <= "+weekEnds; - countSql += " AND A.NOW_WEEKS <= "+weekEnds; - } - - if (StringUtils.isNotEmpty(hbsag)) - { - sql += " AND A.HBSAG = "+hbsag; - countSql += " AND A.HBSAG = "+hbsag; - } - - if (StringUtils.isNotEmpty(hbeag)) - { - sql += " AND A.HBEAG = "+hbeag; - countSql += " AND A.HBEAG = "+hbeag; - } - - if (StringUtils.isNotEmpty(hbeab)) - { - sql += " AND A.HBEAB = "+hbeab; - countSql += " AND A.HBEAB = "+hbeab; - } - - if (StringUtils.isNotEmpty(hbcab)) - { - sql += " AND A.HBCAB = "+hbcab; - countSql += " AND A.HBCAB = "+hbcab; - } - if (StringUtils.isNotEmpty(syphilis)) - { - sql += " AND A.SYPHILIS = "+syphilis; - countSql += " AND A.SYPHILIS = "+syphilis; - } - - if (StringUtils.isNotEmpty(hiv)) - { - sql += " AND A.HIV = "+hiv; - countSql += " AND A.HIV = "+hiv; - } - - if (StringUtils.isNotEmpty(hcv)) - { - sql += " AND A.HCV = "+hcv; - countSql += " AND A.HCV = "+hcv; - } - if (StringUtils.isNotEmpty(doctorNo)) - { - sql += " AND A.DOCTOR_NO = "+doctorNo; - countSql += " AND A.DOCTOR_NO = "+doctorNo; - } - - sql+=" order by A.EXAMINE_DATE DESC,A.Name ASC,A.EXAMINE_ID DESC ) A WHERE ROWNUM <= "+end+" ) WHERE RN >= "+start; - - logger.info(sql); - List> list = JdbcUtil.getListDataBySql(sql); - - Integer count = Integer.parseInt(String.valueOf(JdbcUtil.getOralceSingleObjBySql(countSql))); - BaseListResponse listResponse= new BaseListResponse(); - listResponse.setData(list); - - PageInfo pageInfo = new PageInfo(page, 0,count,limit); - - listResponse.setPageInfo(pageInfo); - - listResponse.setErrorcode(ErrorCodeConstants.SUCCESS); - listResponse.setErrormsg("成功"); - return listResponse; - } - - - public void exportChanReport(Integer userId, HttpServletResponse httpServletResponse, - String exDateStart, - String exDateEnd, - String name, - Integer weekStarts, - Integer weekEnds, - String hbsag, - String hbeag, - String hbeab, - String hbcab, - String syphilis, - String hiv, - String hcv, - String doctorNo) { - String hospitalId = autoMatchFacade.getHospitalId(userId); - String sql = "SELECT A.EXAMINE_DATE,\n" + - " A.NAME,\n" + - " A.AGE,\n" + - " (CASE WHEN A.NOW_WEEKS_DAY<>0 THEN '孕'||A.NOW_WEEKS|| '周+'||A.NOW_WEEKS_DAY||'天' ELSE '孕'||A.NOW_WEEKS|| '周' END) as NOW_WEEKS,\n" + - " A.NOW_WEEKS_DAY, \n" + - " B.EDD_DATE,\n" + - " A.HBSAG,\n" + - " A.HBSAB,\n" + - " A.HBEAG,\n" + - " A.HBEAB,\n" + - " A.HBCAB,\n" + - " A.SYPHILIS,\n" + - " A.HIV,\n" + - " A.HCV,\n" + - " (CASE WHEN A.HIGH_RISK_GRADE IS NULL THEN '绿色预警' ELSE A.HIGH_RISK_GRADE END) AS HIGH_RISK_GRADE,\n" + - " (CASE WHEN A.HIGH_RISK_FACTOR IS NULL THEN '健康' ELSE A.HIGH_RISK_FACTOR END) AS HIGH_RISK_FACTOR,\n" + - " A.NEXT_EXAMINE_DATE,\n" + - " A.EXAMINE_HISTORY_NUM,\n" + - " A.DOCTOR_NAME,\n" + - " A.DOCTOR_NAME AS BOOKER,\n" + - " DECODE(B.IS_VIP_ID,1,'增值服务','标准服务') AS SERVICE_STATUS,\n" + - " A.SUGGESTION,\n" + - " B.TEL_NO,\n" + - " B.HOME_ADDR,\n" + - " B.STREET_VALLAGE_ID,\n" + - " B.STREET_VALLAGE,\n" + - " B.AREA_COUNTY_ID,\n" + - " B.AREA_COUNTY,\n" + - " B.CITY_ID,\n" + - " B.CITY,\n" + - " B.PROVINCE_ID,\n" + - " B.PROVINCE\n" + - " FROM ODS_F_AUXILIARY_EXAMI A " + - " INNER JOIN ODS_F_GRAVIDA_RECORD B ON A.RECORD_ID=B.RECORD_ID \n" + - " INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO AND C.VER_NO=2 \n" + - " WHERE C.YCY_STSTEM_ID= '"+hospitalId +"'"; - if (StringUtils.isNotEmpty(exDateStart)) - { - sql += " AND A.EXAMINE_DATE>= to_date('"+exDateStart+"','yyyy-MM-dd')"; - } - if (StringUtils.isNotEmpty(exDateEnd)) - { - sql += " AND A.EXAMINE_DATE <= to_date('"+exDateEnd+"','yyyy-MM-dd')"; - } - - if (StringUtils.isNotEmpty(name)) - { - sql += " AND A.NAME LIKE '%"+name+"%'"; - } - - if (weekStarts != null) - { - sql += " AND A.NOW_WEEKS>= "+weekStarts; - } - - if (weekEnds != null) - { - sql += " AND A.NOW_WEEKS <= "+weekEnds; - } - - if (StringUtils.isNotEmpty(hbsag)) - { - sql += " AND A.HBSAG = "+hbsag; - } - - if (StringUtils.isNotEmpty(hbeag)) - { - sql += " AND A.HBEAG = "+hbeag; - } - - if (StringUtils.isNotEmpty(hbeab)) - { - sql += " AND A.HBEAB = "+hbeab; - } - - if (StringUtils.isNotEmpty(hbcab)) - { - sql += " AND A.HBCAB = "+hbcab; - } - if (StringUtils.isNotEmpty(syphilis)) - { - sql += " AND A.SYPHILIS = "+syphilis; - } - - if (StringUtils.isNotEmpty(hiv)) - { - sql += " AND A.HIV = "+hiv; - } - - if (StringUtils.isNotEmpty(hcv)) - { - sql += " AND A.HCV = "+hcv; - } - if (StringUtils.isNotEmpty(doctorNo)) - { - sql += " AND A.DOCTOR_NO = "+doctorNo; - } - - sql+=" order by A.EXAMINE_DATE DESC,A.Name ASC,A.EXAMINE_ID DESC "; - - try { - List> datas = JdbcUtil.getListDataBySql(sql); - OutputStream out = httpServletResponse.getOutputStream(); - Map cnames = new LinkedHashMap<>(); - - cnames.put("NAME", "姓名"); - cnames.put("AGE", "年龄"); - cnames.put("NOW_WEEKS", "孕周"); - cnames.put("TEL_NO", "联系方式"); - cnames.put("SUGGESTION", "处理意见"); - cnames.put("HBSAG", "乙肝表面抗原"); - cnames.put("HBSAB", "乙肝表面抗体"); - cnames.put("HBEAG", "乙肝e抗原"); - cnames.put("HBEAB", "乙肝e抗体"); - cnames.put("HBCAB", "乙肝核心抗体"); - cnames.put("SYPHILIS", "梅毒"); - cnames.put("HIV", "HIV"); - cnames.put("HCV", "丙肝"); - cnames.put("NEXT_EXAMINE_DATE", "预约产检日期"); - cnames.put("EXAMINE_HISTORY_NUM", "本院产检次数"); - cnames.put("DOCTOR_NAME", "产检医生"); - cnames.put("BOOKER", "登记人"); - cnames.put("SERVICE_STATUS", "服务类型"); - cnames.put("HIGH_RISK_FACTOR", "高危因素"); - cnames.put("HIGH_RISK_GRADE", "高危等级"); - cnames.put("EDD_DATE", "预产期"); - cnames.put("EXAMINE_DATE", "产检日期"); - cnames.put("HOME_ADDR", "居住地"); - httpServletResponse.setContentType("application/octet-stream"); - httpServletResponse.setCharacterEncoding("UTF-8"); - httpServletResponse.setHeader("Content-Disposition", "attachment;fileName=datas.xls"); - ExcelUtil.toChanExcel(out, datas, cnames); - }catch (Exception e) - { - logger.error(e +"",e); - } - } - - /** - * - * 建档管理页面 - * - * @param bookBuildManagerQueryRequest - * @return - */ - public BaseListResponse queryBookBuild(BookBuildManagerQueryRequest bookBuildManagerQueryRequest,Integer userId){ - PatientsQuery patientsQuery1=new PatientsQuery(); - patientsQuery1.setYn(YnEnums.YES.getId()); - List buildType = new ArrayList(); - buildType.add(0); - buildType.add(2); - patientsQuery1.setBuildTypeList(buildType); - String hospitalId= autoMatchFacade.getHospitalId(userId); - patientsQuery1.setHospitalId(hospitalId); - patientsQuery1.setNeed("1"); - patientsQuery1.setLimit(bookBuildManagerQueryRequest.getLimit()); - patientsQuery1.setPage(bookBuildManagerQueryRequest.getPage()); - patientsQuery1.setPhone(bookBuildManagerQueryRequest.getPhone()); - patientsQuery1.setCardNo(bookBuildManagerQueryRequest.getCardNo()); - patientsQuery1.setPhone(bookBuildManagerQueryRequest.getPhone()); - - List patientses= yunBookbuildingService.queryPregnantWithQuery(patientsQuery1); - - BookBuildManagerResult bookBuildManagerResult=new BookBuildManagerResult(); - List data = new ArrayList<>(); - for(Patients patients: patientses){ - bookBuildManagerResult.convertToResult(patients); - - } - return new BaseListResponse().setData(data).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); - } - - public BaseResponse findPatientById(String parentId,Integer userId){ - PatientsQuery patientsQuery = new PatientsQuery(); - patientsQuery.setId(parentId); - patientsQuery.setYn(YnEnums.YES.getId()); - patientsQuery.setHospitalId(autoMatchFacade.getHospitalId(userId)); - PregnantInfoResult result = new PregnantInfoResult(); - SimplePregnantResult patientResult =new SimplePregnantResult(); - List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); - if (patients != null && patients.size() > 0) - { - Patients p = patients.get(0); - result = getResult(p); - - patientResult.setId(result.getId()); - patientResult.setPid(result.getPid()); - - patientResult.setPregnantName(result.getPregnantName()); - patientResult.setPregnantPhone(result.getPregnantPhone()); - patientResult.setPregnantAge(DateUtil.getAge(p.getBirth()) + ""); - - patientResult.setPregnantLiveAddr(p.getAddressRegister()); - patientResult.setPregnantLiveProvinceId(p.getProvinceRegisterId()); - patientResult.setPregnantLiveCityId(p.getCityRegisterId()); - patientResult.setPregnantLiveAreaId(p.getAreaRegisterId()); - patientResult.setPregnantLiveStreetId(p.getStreetRegisterId()); - - - patientResult.setPregnantLiveProvince(getBasicConfig(patientResult.getPregnantLiveProvinceId())); - patientResult.setPregnantLiveCity(getBasicConfig(patientResult.getPregnantLiveCityId())); - patientResult.setPregnantLiveArea(getBasicConfig(patientResult.getPregnantLiveAreaId())); - patientResult.setPregnantLiveStreet(getBasicConfig(patientResult.getPregnantLiveStreetId())); - patientResult.setHusbandName(result.getHusbandName()); - //丈夫证件号 - if(StringUtils.isNotEmpty(result.getHusbandCertificateNum()) &&result.getHusbandCertificateNum().length()==18){ - - int years,months,days; - try{ - String year = result.getHusbandCertificateNum().substring(6,10); - String month = result.getHusbandCertificateNum().substring(10, 12); - String day = result.getHusbandCertificateNum().substring(12,14); - years=Integer.valueOf(year); - months=Integer.valueOf(month); - days=Integer.valueOf(day); - Calendar calendar=Calendar.getInstance(); - calendar.set(years,months-1,days); - patientResult.setHusbandAge(DateUtil.getAge(calendar.getTime())+""); - }catch (Exception e){ - } - } - - patientResult.setHusbandCertificateNum(result.getHusbandCertificateNum()); - patientResult.setHusbandCertificateTypeId(result.getHusbandCertificateTypeId()); - patientResult.setHusbandPhone(result.getHusbandPhone()); - } - // 增加初诊信息,桓台医院打印使用 - AntExChuQuery antExChuQuery = new AntExChuQuery(); - antExChuQuery.setParentId(patientResult.getId()); - antExChuQuery.setYn(YnEnums.YES.getId()); - List antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery); - if (CollectionUtils.isNotEmpty(antExChuModels)) { - AntExChuModel antExChuModel = antExChuModels.get(0); - patientResult.setPregnancyTimes(antExChuModel.getPregnancyTimes()); - patientResult.setProdTime(antExChuModel.getProdTime()); - patientResult.setDelivery(antExChuModel.getDelivery()); - patientResult.setPlanedProd(antExChuModel.getPlanedProd()); - } - - BaseObjectResponse objectResponse = new BaseObjectResponse(); - objectResponse.setData(patientResult); - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); - objectResponse.setErrormsg("成功"); - return objectResponse; - } - private String getBasicConfig(String id){ - if(StringUtils.isEmpty(id)){ - return ""; - } - BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id); - if(null!=basicConfig){ - return basicConfig.getName(); - } - return ""; - } + if (!deleteProcessHandler.deleteBookBuild(patients.getPid(), patients.getBookbuildingDate(), hospital)) { + return new BaseResponse().setErrorcode(ErrorCodeConstants.DONT_DELETE).setErrormsg("孕妇存在检查记录,不能删除建档"); + } + yunBookbuildingService.deletePregnantById(id); + //删除建档需要删除产筛数据 + SieveQuery sieveQuery = new SieveQuery(); + sieveQuery.setYn(YnEnums.YES.getId()); + sieveQuery.setParentId(id); + sieveService.deleteById(sieveQuery); + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + } + + /** + * 查询孕妇基本信息 通过就诊卡号或者身份证 + * + * @param cardNo + * @param vcCardNo + * @return + */ + public BaseObjectResponse queryYunBuildInfo(String cardNo, String vcCardNo, Integer userId) { + Patients pat = null; + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setYn(YnEnums.YES.getId()); + if (StringUtils.isNotEmpty(cardNo)) { + patientsQuery.setCardNo(cardNo); + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + pat = patients.get(0); + } + } + + String hospitalId = ""; + //得到当前登录的医院id + if (userId != null) { + Users dbuser = usersService.getUsers(userId); + if (dbuser != null) { + hospitalId = String.valueOf(dbuser.getOrgId()); + } + } + + if (StringUtils.isNotEmpty(vcCardNo) && StringUtils.isNotEmpty(hospitalId)) { + patientsQuery.setVcCardNo(vcCardNo); + patientsQuery.setHospitalId(hospitalId); + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(patients)) { + Patients vcCardNoPat = patients.get(0); + patientsQuery.setHospitalId(null); + patientsQuery.setVcCardNo(null); + patientsQuery.setCardNo(vcCardNoPat.getCardNo()); + List cardNoPat = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (CollectionUtils.isNotEmpty(cardNoPat)) { + pat = cardNoPat.get(0); + } + } + } + BaseObjectResponse objectResponse = new BaseObjectResponse(); + if (pat == null) { + objectResponse.setData(""); + } else { + objectResponse.setData(getResult(pat)); + } + + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } + + public BaseObjectResponse queryHospitals(String keyWord, Integer page, Integer limit) { + OrganizationQuery organizationQuery = new OrganizationQuery(); + if (null != page && limit != page) { + organizationQuery.setNeed("true"); + organizationQuery.setPage(page); + organizationQuery.setLimit(limit); + organizationQuery.setSort("modified desc"); + } + + organizationQuery.setYn(YnEnums.YES.getId()); + organizationQuery.setKeyword(keyWord); + + + List> mapList = new ArrayList<>(); + List orgs = organizationService.queryHospitals(organizationQuery); + if (CollectionUtils.isNotEmpty(orgs)) { + for (Organization org : orgs) { + Map map = new HashMap<>(); + map.put("id", org.getId() + ""); + map.put("name", org.getName()); + mapList.add(map); + } + } + + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setData(mapList); + + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } + + public BaseListResponse queryChanJianReport(Integer userId, String exDateStart, + String exDateEnd, + String name, + Integer weekStarts, + Integer weekEnds, + String hbsag, + String hbeag, + String hbeab, + String hbcab, + String syphilis, + String hiv, + String hcv, + String doctorNo, + Integer page, + Integer limit) { + + String hospitalId = autoMatchFacade.getHospitalId(userId); + + int start = 0; + int end = 1000; + if (page != null && limit != null) { + start = (page - 1) * limit + 1; + end = page * limit; + } + String countSql = " SELECT count(*) as allCount " + + "FROM ODS_F_AUXILIARY_EXAMI A\n" + + "INNER JOIN ODS_F_GRAVIDA_RECORD B ON A.RECORD_ID=B.RECORD_ID\n" + + "INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO AND C.VER_NO=2\n" + + "WHERE C.YCY_STSTEM_ID= '" + hospitalId + "'"; + + + String sql = "SELECT * FROM ( SELECT A.*, ROWNUM RN FROM ( SELECT A.EXAMINE_DATE,\n" + + " A.NAME,\n" + + " A.AGE,\n" + + " A.NOW_WEEKS,\n" + + " A.NOW_WEEKS_DAY, \n" + + " B.EDD_DATE,\n" + + " A.HBSAG,\n" + + " A.HBSAB,\n" + + " A.HBEAG,\n" + + " A.HBEAB,\n" + + " A.HBCAB,\n" + + " A.SYPHILIS,\n" + + " A.HIV,\n" + + " A.HCV,\n" + + " (CASE WHEN A.HIGH_RISK_GRADE IS NULL THEN '绿色预警' ELSE A.HIGH_RISK_GRADE END) AS HIGH_RISK_GRADE,\n" + + " (CASE WHEN A.HIGH_RISK_FACTOR IS NULL THEN '健康' ELSE A.HIGH_RISK_FACTOR END) AS HIGH_RISK_FACTOR,\n" + + " A.NEXT_EXAMINE_DATE,\n" + + " A.EXAMINE_HISTORY_NUM,\n" + + " A.DOCTOR_NAME,\n" + + " A.DOCTOR_NAME AS BOOKER,\n" + + " DECODE(B.IS_VIP_ID,1,'增值服务','标准服务') AS SERVICE_STATUS,\n" + + " A.SUGGESTION,\n" + + " B.TEL_NO,\n" + + " B.HOME_ADDR,\n" + + " B.STREET_VALLAGE_ID,\n" + + " B.STREET_VALLAGE,\n" + + " B.AREA_COUNTY_ID,\n" + + " B.AREA_COUNTY,\n" + + " B.CITY_ID,\n" + + " B.CITY,\n" + + " B.PROVINCE_ID,\n" + + " B.PROVINCE\n" + + " FROM ODS_F_AUXILIARY_EXAMI A " + + " INNER JOIN ODS_F_GRAVIDA_RECORD B ON A.RECORD_ID=B.RECORD_ID \n" + + " INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO AND C.VER_NO=2 \n" + + " WHERE C.YCY_STSTEM_ID= '" + hospitalId + "'"; + if (StringUtils.isNotEmpty(exDateStart)) { + sql += " AND A.EXAMINE_DATE>= to_date('" + exDateStart + "','yyyy-MM-dd')"; + countSql += " AND A.EXAMINE_DATE>= to_date('" + exDateStart + "','yyyy-MM-dd')"; + } + if (StringUtils.isNotEmpty(exDateEnd)) { + sql += " AND A.EXAMINE_DATE <= to_date('" + exDateEnd + "','yyyy-MM-dd')"; + countSql += " AND A.EXAMINE_DATE <= to_date('" + exDateEnd + "','yyyy-MM-dd')"; + } + + if (StringUtils.isNotEmpty(name)) { + sql += " AND A.NAME LIKE '%" + name + "%'"; + countSql += " AND A.NAME LIKE '%" + name + "%'"; + } + + if (weekStarts != null) { + sql += " AND A.NOW_WEEKS>= " + weekStarts; + countSql += " AND A.NOW_WEEKS>= " + weekStarts; + } + + if (weekEnds != null) { + sql += " AND A.NOW_WEEKS <= " + weekEnds; + countSql += " AND A.NOW_WEEKS <= " + weekEnds; + } + + if (StringUtils.isNotEmpty(hbsag)) { + sql += " AND A.HBSAG = " + hbsag; + countSql += " AND A.HBSAG = " + hbsag; + } + + if (StringUtils.isNotEmpty(hbeag)) { + sql += " AND A.HBEAG = " + hbeag; + countSql += " AND A.HBEAG = " + hbeag; + } + + if (StringUtils.isNotEmpty(hbeab)) { + sql += " AND A.HBEAB = " + hbeab; + countSql += " AND A.HBEAB = " + hbeab; + } + + if (StringUtils.isNotEmpty(hbcab)) { + sql += " AND A.HBCAB = " + hbcab; + countSql += " AND A.HBCAB = " + hbcab; + } + if (StringUtils.isNotEmpty(syphilis)) { + sql += " AND A.SYPHILIS = " + syphilis; + countSql += " AND A.SYPHILIS = " + syphilis; + } + + if (StringUtils.isNotEmpty(hiv)) { + sql += " AND A.HIV = " + hiv; + countSql += " AND A.HIV = " + hiv; + } + + if (StringUtils.isNotEmpty(hcv)) { + sql += " AND A.HCV = " + hcv; + countSql += " AND A.HCV = " + hcv; + } + if (StringUtils.isNotEmpty(doctorNo)) { + sql += " AND A.DOCTOR_NO = " + doctorNo; + countSql += " AND A.DOCTOR_NO = " + doctorNo; + } + + sql += " order by A.EXAMINE_DATE DESC,A.Name ASC,A.EXAMINE_ID DESC ) A WHERE ROWNUM <= " + end + " ) WHERE RN >= " + start; + + logger.info(sql); + List> list = JdbcUtil.getListDataBySql(sql); + + Integer count = Integer.parseInt(String.valueOf(JdbcUtil.getOralceSingleObjBySql(countSql))); + BaseListResponse listResponse = new BaseListResponse(); + listResponse.setData(list); + + PageInfo pageInfo = new PageInfo(page, 0, count, limit); + + listResponse.setPageInfo(pageInfo); + + listResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + listResponse.setErrormsg("成功"); + return listResponse; + } + + + public void exportChanReport(Integer userId, HttpServletResponse httpServletResponse, + String exDateStart, + String exDateEnd, + String name, + Integer weekStarts, + Integer weekEnds, + String hbsag, + String hbeag, + String hbeab, + String hbcab, + String syphilis, + String hiv, + String hcv, + String doctorNo) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + String sql = "SELECT A.EXAMINE_DATE,\n" + + " A.NAME,\n" + + " A.AGE,\n" + + " (CASE WHEN A.NOW_WEEKS_DAY<>0 THEN '孕'||A.NOW_WEEKS|| '周+'||A.NOW_WEEKS_DAY||'天' ELSE '孕'||A.NOW_WEEKS|| '周' END) as NOW_WEEKS,\n" + + " A.NOW_WEEKS_DAY, \n" + + " B.EDD_DATE,\n" + + " A.HBSAG,\n" + + " A.HBSAB,\n" + + " A.HBEAG,\n" + + " A.HBEAB,\n" + + " A.HBCAB,\n" + + " A.SYPHILIS,\n" + + " A.HIV,\n" + + " A.HCV,\n" + + " (CASE WHEN A.HIGH_RISK_GRADE IS NULL THEN '绿色预警' ELSE A.HIGH_RISK_GRADE END) AS HIGH_RISK_GRADE,\n" + + " (CASE WHEN A.HIGH_RISK_FACTOR IS NULL THEN '健康' ELSE A.HIGH_RISK_FACTOR END) AS HIGH_RISK_FACTOR,\n" + + " A.NEXT_EXAMINE_DATE,\n" + + " A.EXAMINE_HISTORY_NUM,\n" + + " A.DOCTOR_NAME,\n" + + " A.DOCTOR_NAME AS BOOKER,\n" + + " DECODE(B.IS_VIP_ID,1,'增值服务','标准服务') AS SERVICE_STATUS,\n" + + " A.SUGGESTION,\n" + + " B.TEL_NO,\n" + + " B.HOME_ADDR,\n" + + " B.STREET_VALLAGE_ID,\n" + + " B.STREET_VALLAGE,\n" + + " B.AREA_COUNTY_ID,\n" + + " B.AREA_COUNTY,\n" + + " B.CITY_ID,\n" + + " B.CITY,\n" + + " B.PROVINCE_ID,\n" + + " B.PROVINCE\n" + + " FROM ODS_F_AUXILIARY_EXAMI A " + + " INNER JOIN ODS_F_GRAVIDA_RECORD B ON A.RECORD_ID=B.RECORD_ID \n" + + " INNER JOIN ODS_D_HOSPITAL C ON A.HOSPITAL_NO=C.HOSPITAL_NO AND C.VER_NO=2 \n" + + " WHERE C.YCY_STSTEM_ID= '" + hospitalId + "'"; + if (StringUtils.isNotEmpty(exDateStart)) { + sql += " AND A.EXAMINE_DATE>= to_date('" + exDateStart + "','yyyy-MM-dd')"; + } + if (StringUtils.isNotEmpty(exDateEnd)) { + sql += " AND A.EXAMINE_DATE <= to_date('" + exDateEnd + "','yyyy-MM-dd')"; + } + + if (StringUtils.isNotEmpty(name)) { + sql += " AND A.NAME LIKE '%" + name + "%'"; + } + + if (weekStarts != null) { + sql += " AND A.NOW_WEEKS>= " + weekStarts; + } + + if (weekEnds != null) { + sql += " AND A.NOW_WEEKS <= " + weekEnds; + } + + if (StringUtils.isNotEmpty(hbsag)) { + sql += " AND A.HBSAG = " + hbsag; + } + + if (StringUtils.isNotEmpty(hbeag)) { + sql += " AND A.HBEAG = " + hbeag; + } + + if (StringUtils.isNotEmpty(hbeab)) { + sql += " AND A.HBEAB = " + hbeab; + } + + if (StringUtils.isNotEmpty(hbcab)) { + sql += " AND A.HBCAB = " + hbcab; + } + if (StringUtils.isNotEmpty(syphilis)) { + sql += " AND A.SYPHILIS = " + syphilis; + } + + if (StringUtils.isNotEmpty(hiv)) { + sql += " AND A.HIV = " + hiv; + } + + if (StringUtils.isNotEmpty(hcv)) { + sql += " AND A.HCV = " + hcv; + } + if (StringUtils.isNotEmpty(doctorNo)) { + sql += " AND A.DOCTOR_NO = " + doctorNo; + } + + sql += " order by A.EXAMINE_DATE DESC,A.Name ASC,A.EXAMINE_ID DESC "; + + try { + List> datas = JdbcUtil.getListDataBySql(sql); + OutputStream out = httpServletResponse.getOutputStream(); + Map cnames = new LinkedHashMap<>(); + + cnames.put("NAME", "姓名"); + cnames.put("AGE", "年龄"); + cnames.put("NOW_WEEKS", "孕周"); + cnames.put("TEL_NO", "联系方式"); + cnames.put("SUGGESTION", "处理意见"); + cnames.put("HBSAG", "乙肝表面抗原"); + cnames.put("HBSAB", "乙肝表面抗体"); + cnames.put("HBEAG", "乙肝e抗原"); + cnames.put("HBEAB", "乙肝e抗体"); + cnames.put("HBCAB", "乙肝核心抗体"); + cnames.put("SYPHILIS", "梅毒"); + cnames.put("HIV", "HIV"); + cnames.put("HCV", "丙肝"); + cnames.put("NEXT_EXAMINE_DATE", "预约产检日期"); + cnames.put("EXAMINE_HISTORY_NUM", "本院产检次数"); + cnames.put("DOCTOR_NAME", "产检医生"); + cnames.put("BOOKER", "登记人"); + cnames.put("SERVICE_STATUS", "服务类型"); + cnames.put("HIGH_RISK_FACTOR", "高危因素"); + cnames.put("HIGH_RISK_GRADE", "高危等级"); + cnames.put("EDD_DATE", "预产期"); + cnames.put("EXAMINE_DATE", "产检日期"); + cnames.put("HOME_ADDR", "居住地"); + httpServletResponse.setContentType("application/octet-stream"); + httpServletResponse.setCharacterEncoding("UTF-8"); + httpServletResponse.setHeader("Content-Disposition", "attachment;fileName=datas.xls"); + ExcelUtil.toChanExcel(out, datas, cnames); + } catch (Exception e) { + logger.error(e + "", e); + } + } + + /** + * 建档管理页面 + * + * @param bookBuildManagerQueryRequest + * @return + */ + public BaseListResponse queryBookBuild(BookBuildManagerQueryRequest bookBuildManagerQueryRequest, Integer userId) { + PatientsQuery patientsQuery1 = new PatientsQuery(); + patientsQuery1.setYn(YnEnums.YES.getId()); + List buildType = new ArrayList(); + buildType.add(0); + buildType.add(2); + patientsQuery1.setBuildTypeList(buildType); + String hospitalId = autoMatchFacade.getHospitalId(userId); + patientsQuery1.setHospitalId(hospitalId); + patientsQuery1.setNeed("1"); + patientsQuery1.setLimit(bookBuildManagerQueryRequest.getLimit()); + patientsQuery1.setPage(bookBuildManagerQueryRequest.getPage()); + patientsQuery1.setPhone(bookBuildManagerQueryRequest.getPhone()); + patientsQuery1.setCardNo(bookBuildManagerQueryRequest.getCardNo()); + patientsQuery1.setPhone(bookBuildManagerQueryRequest.getPhone()); + + List patientses = yunBookbuildingService.queryPregnantWithQuery(patientsQuery1); + + BookBuildManagerResult bookBuildManagerResult = new BookBuildManagerResult(); + List data = new ArrayList<>(); + for (Patients patients : patientses) { + bookBuildManagerResult.convertToResult(patients); + + } + return new BaseListResponse().setData(data).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); + } + + public BaseResponse findPatientById(String parentId, Integer userId) { + PatientsQuery patientsQuery = new PatientsQuery(); + patientsQuery.setId(parentId); + patientsQuery.setYn(YnEnums.YES.getId()); + patientsQuery.setHospitalId(autoMatchFacade.getHospitalId(userId)); + PregnantInfoResult result = new PregnantInfoResult(); + SimplePregnantResult patientResult = new SimplePregnantResult(); + List patients = yunBookbuildingService.queryPregnantWithQuery(patientsQuery); + if (patients != null && patients.size() > 0) { + Patients p = patients.get(0); + result = getResult(p); + + patientResult.setId(result.getId()); + patientResult.setPid(result.getPid()); + + patientResult.setPregnantName(result.getPregnantName()); + patientResult.setPregnantPhone(result.getPregnantPhone()); + patientResult.setPregnantAge(DateUtil.getAge(p.getBirth()) + ""); + + patientResult.setPregnantLiveAddr(p.getAddressRegister()); + patientResult.setPregnantLiveProvinceId(p.getProvinceRegisterId()); + patientResult.setPregnantLiveCityId(p.getCityRegisterId()); + patientResult.setPregnantLiveAreaId(p.getAreaRegisterId()); + patientResult.setPregnantLiveStreetId(p.getStreetRegisterId()); + + + patientResult.setPregnantLiveProvince(getBasicConfig(patientResult.getPregnantLiveProvinceId())); + patientResult.setPregnantLiveCity(getBasicConfig(patientResult.getPregnantLiveCityId())); + patientResult.setPregnantLiveArea(getBasicConfig(patientResult.getPregnantLiveAreaId())); + patientResult.setPregnantLiveStreet(getBasicConfig(patientResult.getPregnantLiveStreetId())); + patientResult.setHusbandName(result.getHusbandName()); + //丈夫证件号 + if (StringUtils.isNotEmpty(result.getHusbandCertificateNum()) && result.getHusbandCertificateNum().length() == 18) { + + int years, months, days; + try { + String year = result.getHusbandCertificateNum().substring(6, 10); + String month = result.getHusbandCertificateNum().substring(10, 12); + String day = result.getHusbandCertificateNum().substring(12, 14); + years = Integer.valueOf(year); + months = Integer.valueOf(month); + days = Integer.valueOf(day); + Calendar calendar = Calendar.getInstance(); + calendar.set(years, months - 1, days); + patientResult.setHusbandAge(DateUtil.getAge(calendar.getTime()) + ""); + } catch (Exception e) { + } + } + + patientResult.setHusbandCertificateNum(result.getHusbandCertificateNum()); + patientResult.setHusbandCertificateTypeId(result.getHusbandCertificateTypeId()); + patientResult.setHusbandPhone(result.getHusbandPhone()); + } + // 增加初诊信息,桓台医院打印使用 + AntExChuQuery antExChuQuery = new AntExChuQuery(); + antExChuQuery.setParentId(patientResult.getId()); + antExChuQuery.setYn(YnEnums.YES.getId()); + List antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery); + if (CollectionUtils.isNotEmpty(antExChuModels)) { + AntExChuModel antExChuModel = antExChuModels.get(0); + patientResult.setPregnancyTimes(antExChuModel.getPregnancyTimes()); + patientResult.setProdTime(antExChuModel.getProdTime()); + patientResult.setDelivery(antExChuModel.getDelivery()); + patientResult.setPlanedProd(antExChuModel.getPlanedProd()); + } + + BaseObjectResponse objectResponse = new BaseObjectResponse(); + objectResponse.setData(patientResult); + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); + objectResponse.setErrormsg("成功"); + return objectResponse; + } + + private String getBasicConfig(String id) { + if (StringUtils.isEmpty(id)) { + return ""; + } + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id); + if (null != basicConfig) { + return basicConfig.getName(); + } + return ""; + } } \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java index 8e6a3d3..6adb608 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/MatDeliverFacade.java @@ -70,8 +70,9 @@ public class MatDeliverFacade { private BabyBookbuildingFacade babyBookbuildingFacade; @Autowired private DeleteProcessHandler deleteProcessHandler; - @Value(("#{configProperties['run.region']}")) - private String runType; + + @Autowired + private OrganizationGroupsFacade organizationGroupsFacade; private static Map ONE_ENUMS = new HashMap<>(); @@ -125,8 +126,10 @@ public class MatDeliverFacade { List babyList = new ArrayList<>(); String hospitalId = autoMatchFacade.getHospitalId(userId); MaternalDeliverModel maternalDeliverModel = deliverAddRequest.convertToDataModel(); + + Organization og = organizationService.getOrganization(Integer.valueOf(hospitalId)); //区域模式 - if (ErrorCodeConstants.RUN_MODE.equals(runType)) { + if (og.getbStatus()!=1) { String parentId =antenatalExaminationFacade.handHideBuild(deliverAddRequest.getPid(), deliverAddRequest.getParentId(), userId); if (StringUtils.isEmpty(parentId)) { logger.warn("get handHideBuild parentId is null."); @@ -468,9 +471,6 @@ public class MatDeliverFacade { personModel.setName(babyModel.getName()); personModel.setCreated(new Date()); babyModel.setPid(personService.addPerson(personModel).getId()); - - - } babyIds.add(babyService.addOneBaby(babyModel).getId()); if ((RenShenJieJuEnums.O.getId() + "").equals(baby.getPregnancyOut())) { @@ -478,7 +478,6 @@ public class MatDeliverFacade { //儿童建档 babyBookbuildingFacade.createBuildSms(babyModel); } - i++; } maternalDeliverModel.setBaby(babyList); @@ -492,21 +491,17 @@ public class MatDeliverFacade { * @return */ public BaseResponse queryMatDeliver(MatDeliverQueryRequest deliverQueryRequest, Integer userId) { - List list1 = autoMatchFacade.matchOrgId(userId); - String hospital = null; - if (CollectionUtils.isNotEmpty(list1)) { - hospital = list1.get(0) + ""; - } + + String hospital=autoMatchFacade.getHospitalId(userId); //获取 /* Patients patients = antenatalExaminationFacade.findOnePatient(deliverQueryRequest.getCardNo(), deliverQueryRequest.getVcCardNo(), null, hospital, -1); if (null == patients) { return new BaseResponse().setErrormsg("没有相关的产妇记录").setErrorcode(ErrorCodeConstants.BUSINESS_ERROR); }*/ + + Organization og = organizationService.getOrganization(Integer.valueOf(hospital)); //区域模式 - boolean isEnable=false; - if (ErrorCodeConstants.RUN_MODE.equals(runType)) { - isEnable=true; - } + boolean isEnable=og.getbStatus()==1; //外院的孕妇 Patients patients1 = antenatalExaminationFacade.findOnePatient(deliverQueryRequest.getCardNo(), deliverQueryRequest.getVcCardNo(), null, null, 1, false, null,true); @@ -515,9 +510,9 @@ public class MatDeliverFacade { //http://jira.healthbaby.com.cn/browse/WEB-204 修改bug //本院的孕妇 - Patients patients = antenatalExaminationFacade.findOnePatient(deliverQueryRequest.getCardNo(), deliverQueryRequest.getVcCardNo(), null, hospital, 1, false, null,isEnable); + Patients patients = antenatalExaminationFacade.findOnePatient(deliverQueryRequest.getCardNo(), deliverQueryRequest.getVcCardNo(), null, organizationGroupsFacade.findGroupHospital(userId), 1, false, null,isEnable); //本院产妇 - Patients patients3 = antenatalExaminationFacade.findOnePatient(deliverQueryRequest.getCardNo(), deliverQueryRequest.getVcCardNo(), null, hospital, 3, false, null,isEnable); + Patients patients3 = antenatalExaminationFacade.findOnePatient(deliverQueryRequest.getCardNo(), deliverQueryRequest.getVcCardNo(), null, organizationGroupsFacade.findGroupHospital(userId), 3, false, null,isEnable); PersonModelQuery personModelQuery = new PersonModelQuery(); String pid = ""; if (null != patients1) { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java index 769c3a0..715f09b 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java @@ -71,6 +71,8 @@ public class PatientFacade { private DataPermissionService dataPermissionService; @Autowired private OrganizationService organizationService; + @Autowired + private OrganizationGroupsFacade groupsFacade; private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(15, 20, 1, TimeUnit.MINUTES, new LinkedBlockingQueue(5000)); @@ -458,7 +460,7 @@ public class PatientFacade { patientsQuery.setPhone(patientQueryRequest.getPhone()); patientsQuery.setCardNo(patientQueryRequest.getCardNo()); String hospital = autoMatchFacade.getHospitalId(userId); - Patients patients = antenatalExaminationFacade.findOnePatient(patientQueryRequest.getCardNo(), null, patientQueryRequest.getId(), hospital, -1, false, patientQueryRequest.getPid(),false); + Patients patients = antenatalExaminationFacade.findOnePatient(patientQueryRequest.getCardNo(), null, patientQueryRequest.getId(), groupsFacade.findGroupHospital(userId), -1, false, patientQueryRequest.getPid(),false); PatientBaseResult patientBaseResult = new PatientBaseResult(); if (null != patients) { patientBaseResult.convert(patients); diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PostReviewFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PostReviewFacade.java index c3ba32c..d2b19cc 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PostReviewFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PostReviewFacade.java @@ -1,9 +1,6 @@ package com.lyms.platform.operate.web.facade; -import com.lyms.platform.biz.service.ApplyOrderService; -import com.lyms.platform.biz.service.MatDeliverService; -import com.lyms.platform.biz.service.PatientsService; -import com.lyms.platform.biz.service.PostReviewService; +import com.lyms.platform.biz.service.*; import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.enums.ServiceStatusEnums; import com.lyms.platform.common.enums.ServiceTypeEnums; @@ -24,7 +21,6 @@ import com.lyms.platform.permission.model.Users; import com.lyms.platform.permission.service.OrganizationService; import com.lyms.platform.permission.service.UsersService; import com.lyms.platform.pojo.*; -import com.lyms.platform.query.AntExQuery; import com.lyms.platform.query.MatDeliverQuery; import com.lyms.platform.query.PostReviewQuery; import com.lyms.platform.query.ReferralApplyOrderQuery; @@ -32,7 +28,6 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Component; @@ -40,7 +35,7 @@ import java.util.*; /** * 产后复查门面 - *

+ *

* Created by Administrator on 2016/6/28 0028. */ @Component @@ -62,40 +57,44 @@ public class PostReviewFacade { private UsersService usersService; @Autowired private ApplyOrderService applyOrderService; - @Value(("#{configProperties['run.region']}")) - private String runType; + @Autowired + private OrganizationGroupsFacade groupsFacade; + @Autowired + private OrganizationGroupsService groupsService; /** - * * 增加产后复查记录 + *

+ * 3、当前孕妇在系统中的本次妊娠期处于已分娩(孕周大于41+6孕周自动分娩、做了分娩记录、儿童建档对应的孕妇分娩),但该孕妇在本院未建档,点击查询进入新增复查界面;在保存产后复查时要自动给该产妇建档(建档的基本信息为该产妇在系统中最新的建档信息) + *

+ * 4、当通过产后复查给产妇建档时,如果查询到该产妇在本院有patient数据并且该patient的buildType=1,则要把该patient的buildType更新为0(防止儿童建档时产生了产妇建档数据,在添加产后复查时重复给该产妇建档) * - * 3、当前孕妇在系统中的本次妊娠期处于已分娩(孕周大于41+6孕周自动分娩、做了分娩记录、儿童建档对应的孕妇分娩),但该孕妇在本院未建档,点击查询进入新增复查界面;在保存产后复查时要自动给该产妇建档(建档的基本信息为该产妇在系统中最新的建档信息) - - 4、当通过产后复查给产妇建档时,如果查询到该产妇在本院有patient数据并且该patient的buildType=1,则要把该patient的buildType更新为0(防止儿童建档时产生了产妇建档数据,在添加产后复查时重复给该产妇建档) - * @param postReviewRequest * @param userId * @return */ - public BaseResponse addPostReview(PostReviewRequest postReviewRequest,Integer userId) { + public BaseResponse addPostReview(PostReviewRequest postReviewRequest, Integer userId) { PostReviewModel postReviewModel = postReviewRequest.convertToDataModel(); - //表示区域的 - if (ErrorCodeConstants.RUN_MODE.equals(runType)) { - String parentId = examinationFacade.handHideBuild(postReviewRequest.getPid(), postReviewRequest.getParentId(), userId); - if (StringUtils.isEmpty(parentId)) { - //打印日志 + String hospital = autoMatchFacade.getHospitalId(userId); + String groupId=groupsFacade.findByCurrentUserId(hospital); + if(StringUtils.isNotEmpty(groupId)){ + OrganizationGroups gorp= groupsService.findById(groupId); + if (gorp.getbType()!=1) { + String parentId = examinationFacade.handHideBuild(postReviewRequest.getPid(), postReviewRequest.getParentId(), userId); + if (StringUtils.isEmpty(parentId)) { + //打印日志 + } + postReviewModel.setParentId(parentId); } - postReviewModel.setParentId(parentId); } //获取数据 Patients patients1 = patientsService.findOnePatientById(postReviewRequest.getParentId()); - String hospital= autoMatchFacade.getHospitalId(userId); postReviewModel.setOperator(userId); //判断是否是同一个医院 - if(!patients1.getHospitalId().equals(hospital)){ + if (!patients1.getHospitalId().equals(hospital)) { patients1.setId(null); patients1.setHospitalId(hospital); patients1.setBuildType(0); @@ -113,7 +112,7 @@ public class PostReviewFacade { postReviewModel.setYn(YnEnums.YES.getId()); postReviewModel.setHospitalId(hospital); Patients patients = patientsService.findOnePatientById(postReviewRequest.getParentId()); - if(StringUtils.isNotEmpty(postReviewRequest.getDueDate())){ + if (StringUtils.isNotEmpty(postReviewRequest.getDueDate())) { patients.setFmDate(DateUtil.parseYMD(postReviewRequest.getDueDate())); patients.setType(3); patients.setEnable("1"); @@ -124,20 +123,19 @@ public class PostReviewFacade { postReviewService.addPostReview(postReviewModel); - if(null!=patients1.getPostViewTimes()){ - Patients patients2=new Patients(); - patients2.setPostViewTimes(patients1.getPostViewTimes()+1); + if (null != patients1.getPostViewTimes()) { + Patients patients2 = new Patients(); + patients2.setPostViewTimes(patients1.getPostViewTimes() + 1); patients2.setId(patients1.getId()); patientsService.updatePatient(patients2); - }else{ - Patients patients2=new Patients(); + } else { + Patients patients2 = new Patients(); patients2.setPostViewTimes(1); patients2.setId(patients1.getId()); patientsService.updatePatient(patients2); } - if (null != patients.getBuildType() && patients.getBuildType() == 3) { ReferralApplyOrderQuery referralApplyOrderQuery = new ReferralApplyOrderQuery(); referralApplyOrderQuery.setParentId(patients.getId()); @@ -169,7 +167,7 @@ public class PostReviewFacade { } else { Patients patients = patientsService.findOnePatientById(postReviewRequest.getParentId()); - if(StringUtils.isNotEmpty(postReviewRequest.getDueDate())){ + if (StringUtils.isNotEmpty(postReviewRequest.getDueDate())) { patients.setFmDate(DateUtil.parseYMD(postReviewRequest.getDueDate())); patients.setType(3); patientsService.updatePatient(patients); @@ -180,41 +178,35 @@ public class PostReviewFacade { } /** - * * 1、当前孕妇在系统中的本次妊娠期处于未分娩/已终止妊娠或在结束上次妊娠期后再次新增了建档,不管该孕妇在本院是否建档,点击查询时提示当前用户未分娩,不能进行复查 - - 2、当前孕妇在系统中的本次妊娠期处于已分娩(孕周大于41+6孕周自动分娩、做了分娩记录、儿童建档对应的孕妇分娩),并且该孕妇在本院已建档,点击查询进入新增复查界面 - - 3、当前孕妇在系统中的本次妊娠期处于已分娩(孕周大于41+6孕周自动分娩、做了分娩记录、儿童建档对应的孕妇分娩),但该孕妇在本院未建档,点击查询进入新增复查界面;在保存产后复查时要自动给该产妇建档(建档的基本信息为该产妇在系统中最新的建档信息) - - 4、当通过产后复查给产妇建档时,如果查询到该产妇在本院有patient数据并且该patient的buildType=1,则要把该patient的buildType更新为0(防止儿童建档时产生了产妇建档数据,在添加产后复查时重复给该产妇建档) + *

+ * 2、当前孕妇在系统中的本次妊娠期处于已分娩(孕周大于41+6孕周自动分娩、做了分娩记录、儿童建档对应的孕妇分娩),并且该孕妇在本院已建档,点击查询进入新增复查界面 + *

+ * 3、当前孕妇在系统中的本次妊娠期处于已分娩(孕周大于41+6孕周自动分娩、做了分娩记录、儿童建档对应的孕妇分娩),但该孕妇在本院未建档,点击查询进入新增复查界面;在保存产后复查时要自动给该产妇建档(建档的基本信息为该产妇在系统中最新的建档信息) + *

+ * 4、当通过产后复查给产妇建档时,如果查询到该产妇在本院有patient数据并且该patient的buildType=1,则要把该patient的buildType更新为0(防止儿童建档时产生了产妇建档数据,在添加产后复查时重复给该产妇建档) * * @param postReviewQueryRequest * @param userId * @return */ - public BaseResponse queryPostList(PostReviewQueryRequest postReviewQueryRequest,Integer userId) { - Patients patients=null; - if(ErrorCodeConstants.RUN_MODE.equals(runType)){ - patients = examinationFacade.findOnePatient(postReviewQueryRequest.getCardNo(), postReviewQueryRequest.getVcCardNo(), null, null, 1,false,null,true); - }else { - patients = examinationFacade.findOnePatient(postReviewQueryRequest.getCardNo(), postReviewQueryRequest.getVcCardNo(), null, null, 1,false,null,false); - } + public BaseResponse queryPostList(PostReviewQueryRequest postReviewQueryRequest, Integer userId) { + String hospitalId = autoMatchFacade.getHospitalId(userId); + Organization og = organizationService.getOrganization(Integer.valueOf(hospitalId)); + Patients patients = examinationFacade.findOnePatient(postReviewQueryRequest.getCardNo(), postReviewQueryRequest.getVcCardNo(), null, null, 1, false, null, og.getbStatus() != 1); //未分娩建档 - if(null!=patients){ + if (null != patients) { return new BaseResponse().setErrorcode(ErrorCodeConstants.PARAMETER_ERROR).setErrormsg("该孕妇还未分娩,不能进行复查"); } - - - String hospitalId = autoMatchFacade.getHospitalId(userId); //取所有医院的建档数据 优先取本院 ,然后取外院 - Patients patientsList = examinationFacade.findOnePatient(postReviewQueryRequest.getCardNo(), postReviewQueryRequest.getVcCardNo(), null, hospitalId, 3,true,null,true); + + Patients patientsList = examinationFacade.findOnePatient(postReviewQueryRequest.getCardNo(), postReviewQueryRequest.getVcCardNo(), null, groupsFacade.findGroupHospital(userId), 3, true, null, og.getbStatus() != 1); PostReviewListResult postReviewListResult = new PostReviewListResult(); if (null != patientsList) { - if(null!=patientsList.getDueStatus() && 1 == patientsList.getDueStatus()){ + if (null != patientsList.getDueStatus() && 1 == patientsList.getDueStatus()) { return new BaseResponse().setErrorcode(ErrorCodeConstants.BUSINESS_ERROR).setErrormsg("该孕妇已终止妊娠,不能进行复查"); } @@ -229,22 +221,22 @@ public class PostReviewFacade { postReviewQuery.setYn(YnEnums.YES.getId()); postReviewQuery.setStart(patientsList.getFmDate()); List postReviewModels = postReviewService.findWithList(postReviewQuery); - String dueDate=""; - if(CollectionUtils.isNotEmpty(list)){ - dueDate= list.get(0).getDueDate(); - }else if(patientsList.getType()==3){ - dueDate=DateUtil.getyyyy_MM_dd(patientsList.getFmDate()); + String dueDate = ""; + if (CollectionUtils.isNotEmpty(list)) { + dueDate = list.get(0).getDueDate(); + } else if (patientsList.getType() == 3) { + dueDate = DateUtil.getyyyy_MM_dd(patientsList.getFmDate()); } - HighScoreResult highScoreResult = examinationFacade.findLastRisk(patientsList.getPid(),false); + HighScoreResult highScoreResult = examinationFacade.findLastRisk(patientsList.getPid(), false); List dataList = new ArrayList<>(); postReviewListResult.setLastBuildTime(DateUtil.getyyyy_MM_dd(patientsList.getFmDate())); - if(CollectionUtils.isNotEmpty(postReviewModels)){ - String hospitalName=""; - for(PostReviewModel model:postReviewModels){ + if (CollectionUtils.isNotEmpty(postReviewModels)) { + String hospitalName = ""; + for (PostReviewModel model : postReviewModels) { Organization organization = organizationService.getOrganization(NumberUtils.toInt(model.getHospitalId())); - if(null!=organization){ - hospitalName=organization.getName(); + if (null != organization) { + hospitalName = organization.getName(); } dataList.add(new AntData(model, hospitalName, DateUtil.parseYMD(dueDate))); } @@ -261,7 +253,6 @@ public class PostReviewFacade { } - /** * 根据id 获取产后记录 * @@ -274,13 +265,13 @@ public class PostReviewFacade { Assert.notNull(postReviewModel, "没有对应的数据."); PostReviewResult postReviewResult = new PostReviewResult(); postReviewResult.convertToResult(postReviewModel); - java.util.Map map = new HashMap<>(); - if(NumberUtils.isNumber(postReviewModel.getProdDoctor())){ + java.util.Map map = new HashMap<>(); + if (NumberUtils.isNumber(postReviewModel.getProdDoctor())) { Users users = usersService.getUsers(Integer.valueOf(postReviewModel.getProdDoctor())); - if(null!=users){ - map.put("id",users.getId()+""); - map.put("name",users.getName()); + if (null != users) { + map.put("id", users.getId() + ""); + map.put("name", users.getName()); } } postReviewResult.setProdDoctor(map); @@ -289,9 +280,9 @@ public class PostReviewFacade { postReviewResult.setHospitalName(organization.getName()); }*/ try { - if(StringUtils.isNotEmpty(postReviewModel.getDiagnosis())){ + if (StringUtils.isNotEmpty(postReviewModel.getDiagnosis())) { List list = JsonUtil.toList(postReviewModel.getDiagnosis(), List.class); - postReviewResult.setDiagnosis(examinationFacade.queryRisk(list,false).getHighRisk()); + postReviewResult.setDiagnosis(examinationFacade.queryRisk(list, false).getHighRisk()); } } catch (Exception e) { } @@ -300,17 +291,18 @@ public class PostReviewFacade { /** * 修改数据 + * * @param id * @return */ - public BaseResponse updateOnePost(String id,Integer userId){ + public BaseResponse updateOnePost(String id, Integer userId) { String hospital = autoMatchFacade.getHospitalId(userId); PostReviewQuery antExQuery = new PostReviewQuery(); antExQuery.setId(id); antExQuery.setYn(YnEnums.YES.getId()); antExQuery.setHospitalId(hospital); - List list = postReviewService.findWithList(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC,"checkTime")); + List list = postReviewService.findWithList(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkTime")); //TODO 需要根据时间去查询是否是本院最后一条记录 if (CollectionUtils.isNotEmpty(list)) { antExQuery.setStart(new Date(list.get(0).getCheckTime().getTime() + 40000)); @@ -318,17 +310,17 @@ public class PostReviewFacade { } antExQuery.setId(null); - list =postReviewService.findWithList(antExQuery.convertToQuery()); - if(CollectionUtils.isNotEmpty(list)){ - for(int i=0;i