Commit 20e26f0fed55c3bbd2eb1b2f2ff577b085d73d21
1 parent
f6b6b147b0
Exists in
master
and in
6 other branches
新生儿访视相关
Showing 6 changed files with 196 additions and 60 deletions
- platform-common/src/main/java/com/lyms/platform/common/result/ResponseCode.java
- platform-dal/src/main/java/com/lyms/platform/pojo/NewbornVisit.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/NewbornVisitControoler.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/INewbornVisitService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/NewbornServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java
platform-common/src/main/java/com/lyms/platform/common/result/ResponseCode.java
View file @
20e26f0
| ... | ... | @@ -27,7 +27,9 @@ | 
| 27 | 27 | COUPON_NOT_UNIQUE(1002, "优惠券有多个"), | 
| 28 | 28 | COUPON_TIME_OUT(1003, "当前优惠券不在使用时间范围内"), | 
| 29 | 29 | COUPON_IS_USERD(1004, "优惠券已被使用"), | 
| 30 | - COUPON_IS_DISABLED(1005, "优惠券已被禁用"); | |
| 30 | + COUPON_IS_DISABLED(1005, "优惠券已被禁用"), | |
| 31 | + | |
| 32 | + NEED_BUILD(1101, "未找到建档信息"); | |
| 31 | 33 | |
| 32 | 34 | private Integer code; | 
| 33 | 35 | private String msg; | 
platform-dal/src/main/java/com/lyms/platform/pojo/NewbornVisit.java
View file @
20e26f0
| ... | ... | @@ -21,10 +21,14 @@ | 
| 21 | 21 | // 操作人ID | 
| 22 | 22 | private String operationId; | 
| 23 | 23 | |
| 24 | + private String hositalId; | |
| 25 | + | |
| 24 | 26 | private String parentId; | 
| 25 | 27 | |
| 26 | 28 | private String babyId; | 
| 27 | 29 | |
| 30 | + private String pid; | |
| 31 | + | |
| 28 | 32 | // 访视时间 | 
| 29 | 33 | private Date checkTime; | 
| 30 | 34 | |
| ... | ... | @@ -32,7 +36,7 @@ | 
| 32 | 36 | private String checkTimeDesc; | 
| 33 | 37 | |
| 34 | 38 | // 访视机构 | 
| 35 | - private String hospitalId; | |
| 39 | + private String visitHositalId; | |
| 36 | 40 | |
| 37 | 41 | // 喂养方式 纯母乳/混合/人工 | 
| 38 | 42 | private String feedType; | 
| ... | ... | @@ -142,22 +146,6 @@ | 
| 142 | 146 | // 下次访视时间说明 | 
| 143 | 147 | private String nextVisitTimeDesc; | 
| 144 | 148 | |
| 145 | - public String getParentId() { | |
| 146 | - return parentId; | |
| 147 | - } | |
| 148 | - | |
| 149 | - public void setParentId(String parentId) { | |
| 150 | - this.parentId = parentId; | |
| 151 | - } | |
| 152 | - | |
| 153 | - public String getBabyId() { | |
| 154 | - return babyId; | |
| 155 | - } | |
| 156 | - | |
| 157 | - public void setBabyId(String babyId) { | |
| 158 | - this.babyId = babyId; | |
| 159 | - } | |
| 160 | - | |
| 161 | 149 | public String getId() { | 
| 162 | 150 | return id; | 
| 163 | 151 | } | 
| ... | ... | @@ -182,6 +170,46 @@ | 
| 182 | 170 | this.yn = yn; | 
| 183 | 171 | } | 
| 184 | 172 | |
| 173 | + public String getOperationId() { | |
| 174 | + return operationId; | |
| 175 | + } | |
| 176 | + | |
| 177 | + public void setOperationId(String operationId) { | |
| 178 | + this.operationId = operationId; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public String getHositalId() { | |
| 182 | + return hositalId; | |
| 183 | + } | |
| 184 | + | |
| 185 | + public void setHositalId(String hositalId) { | |
| 186 | + this.hositalId = hositalId; | |
| 187 | + } | |
| 188 | + | |
| 189 | + public String getParentId() { | |
| 190 | + return parentId; | |
| 191 | + } | |
| 192 | + | |
| 193 | + public void setParentId(String parentId) { | |
| 194 | + this.parentId = parentId; | |
| 195 | + } | |
| 196 | + | |
| 197 | + public String getBabyId() { | |
| 198 | + return babyId; | |
| 199 | + } | |
| 200 | + | |
| 201 | + public void setBabyId(String babyId) { | |
| 202 | + this.babyId = babyId; | |
| 203 | + } | |
| 204 | + | |
| 205 | + public String getPid() { | |
| 206 | + return pid; | |
| 207 | + } | |
| 208 | + | |
| 209 | + public void setPid(String pid) { | |
| 210 | + this.pid = pid; | |
| 211 | + } | |
| 212 | + | |
| 185 | 213 | public Date getCheckTime() { | 
| 186 | 214 | return checkTime; | 
| 187 | 215 | } | 
| 188 | 216 | |
| ... | ... | @@ -198,12 +226,12 @@ | 
| 198 | 226 | this.checkTimeDesc = checkTimeDesc; | 
| 199 | 227 | } | 
| 200 | 228 | |
| 201 | - public String getHospitalId() { | |
| 202 | - return hospitalId; | |
| 229 | + public String getVisitHositalId() { | |
| 230 | + return visitHositalId; | |
| 203 | 231 | } | 
| 204 | 232 | |
| 205 | - public void setHospitalId(String hospitalId) { | |
| 206 | - this.hospitalId = hospitalId; | |
| 233 | + public void setVisitHositalId(String visitHositalId) { | |
| 234 | + this.visitHositalId = visitHositalId; | |
| 207 | 235 | } | 
| 208 | 236 | |
| 209 | 237 | public String getFeedType() { | 
| ... | ... | @@ -300,14 +328,6 @@ | 
| 300 | 328 | |
| 301 | 329 | public void setRespiratoryRate(String respiratoryRate) { | 
| 302 | 330 | this.respiratoryRate = respiratoryRate; | 
| 303 | - } | |
| 304 | - | |
| 305 | - public String getOperationId() { | |
| 306 | - return operationId; | |
| 307 | - } | |
| 308 | - | |
| 309 | - public void setOperationId(String operationId) { | |
| 310 | - this.operationId = operationId; | |
| 311 | 331 | } | 
| 312 | 332 | |
| 313 | 333 | public String getSkin() { | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/NewbornVisitControoler.java
View file @
20e26f0
| ... | ... | @@ -11,6 +11,7 @@ | 
| 11 | 11 | import org.springframework.web.bind.annotation.ResponseBody; | 
| 12 | 12 | |
| 13 | 13 | import javax.servlet.http.HttpServletRequest; | 
| 14 | +import java.util.Date; | |
| 14 | 15 | |
| 15 | 16 | /** | 
| 16 | 17 | * 新生儿访视 | 
| ... | ... | @@ -26,7 +27,21 @@ | 
| 26 | 27 | @RequestMapping(method = RequestMethod.POST) | 
| 27 | 28 | @ResponseBody | 
| 28 | 29 | public BaseObjectResponse add(HttpServletRequest request, NewbornVisit newbornVisit) { | 
| 29 | - return visitService.add(getUserId(request), newbornVisit); | |
| 30 | + return visitService.addOrUpdate(getUserId(request), newbornVisit); | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 新生儿访视管理 | |
| 35 | + * @param startDate 访视开始日期 | |
| 36 | + * @param endDate 访视结束日期 | |
| 37 | + * @param doctor 访视医生 | |
| 38 | + * @param key 儿童姓名(模糊查询)/母亲联系方式/母亲证件号 | |
| 39 | + * @return | |
| 40 | + */ | |
| 41 | + @RequestMapping(method = RequestMethod.GET) | |
| 42 | + @ResponseBody | |
| 43 | + public BaseObjectResponse list(HttpServletRequest request, Date startDate, Date endDate, String doctor, String key, Integer page, Integer limit) { | |
| 44 | + return visitService.list(startDate, endDate, doctor, getUserId(request), key, page, limit); | |
| 30 | 45 | } | 
| 31 | 46 | |
| 32 | 47 | @RequestMapping(value = "/init", method = RequestMethod.GET) | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/INewbornVisitService.java
View file @
20e26f0
| ... | ... | @@ -3,14 +3,14 @@ | 
| 3 | 3 | import com.lyms.platform.common.result.BaseObjectResponse; | 
| 4 | 4 | import com.lyms.platform.pojo.NewbornVisit; | 
| 5 | 5 | |
| 6 | -import javax.servlet.http.HttpServletResponse; | |
| 7 | 6 | import java.util.Date; | 
| 8 | -import java.util.Map; | |
| 9 | 7 | |
| 10 | 8 | public interface INewbornVisitService extends IBaseService { | 
| 11 | 9 | |
| 12 | 10 | BaseObjectResponse init(); | 
| 13 | 11 | |
| 14 | - BaseObjectResponse add(Integer userId, NewbornVisit newbornVisit); | |
| 12 | + BaseObjectResponse addOrUpdate(Integer userId, NewbornVisit newbornVisit); | |
| 13 | + | |
| 14 | + BaseObjectResponse list(Date startDate, Date endDate, String doctor, Integer userId, String key, Integer page, Integer limit); | |
| 15 | 15 | } | 
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/NewbornServiceImpl.java
View file @
20e26f0
| 1 | 1 | package com.lyms.platform.operate.web.service.impl; | 
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.lyms.hospitalapi.pojo.ReportModel; | |
| 5 | -import com.lyms.platform.biz.service.CommonService; | |
| 3 | +import com.lyms.platform.biz.service.DataPermissionService; | |
| 6 | 4 | import com.lyms.platform.common.enums.*; | 
| 7 | 5 | import com.lyms.platform.common.result.BaseObjectResponse; | 
| 8 | 6 | import com.lyms.platform.common.result.PageResult; | 
| 9 | 7 | import com.lyms.platform.common.result.RespBuilder; | 
| 8 | +import com.lyms.platform.common.result.ResponseCode; | |
| 10 | 9 | import com.lyms.platform.common.utils.DateUtil; | 
| 11 | 10 | import com.lyms.platform.common.utils.EnumUtil; | 
| 12 | -import com.lyms.platform.operate.web.dao.IReportDao; | |
| 13 | -import com.lyms.platform.operate.web.facade.AccessPermissionFacade; | |
| 11 | +import com.lyms.platform.common.utils.MongoConvertHelper; | |
| 12 | +import com.lyms.platform.common.utils.ReflectionUtils; | |
| 14 | 13 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; | 
| 15 | 14 | import com.lyms.platform.operate.web.service.INewbornVisitService; | 
| 16 | -import com.lyms.platform.operate.web.service.IReportService; | |
| 17 | -import com.lyms.platform.operate.web.utils.*; | |
| 18 | -import com.lyms.platform.permission.dao.master.CouponMapper; | |
| 19 | -import com.lyms.platform.permission.model.Organization; | |
| 15 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
| 16 | +import com.lyms.platform.operate.web.utils.MongoUtil; | |
| 17 | +import com.lyms.platform.permission.dao.slave.UsersMapper; | |
| 20 | 18 | import com.lyms.platform.permission.model.Users; | 
| 21 | -import com.lyms.platform.permission.service.OrganizationService; | |
| 22 | -import com.lyms.platform.permission.service.UsersService; | |
| 23 | 19 | import com.lyms.platform.pojo.*; | 
| 24 | -import com.lymsh.platform.reportdata.model.echarts.Series; | |
| 25 | -import org.apache.commons.collections.MapUtils; | |
| 20 | +import com.lyms.platform.query.DataPermissionsModelQuery; | |
| 26 | 21 | import org.apache.commons.lang.StringUtils; | 
| 27 | 22 | import org.springframework.beans.factory.annotation.Autowired; | 
| 28 | 23 | import org.springframework.data.domain.Sort; | 
| 29 | 24 | import org.springframework.data.mongodb.core.MongoTemplate; | 
| 30 | 25 | import org.springframework.data.mongodb.core.query.Criteria; | 
| 31 | 26 | import org.springframework.data.mongodb.core.query.Query; | 
| 27 | +import org.springframework.data.mongodb.core.query.Update; | |
| 32 | 28 | import org.springframework.stereotype.Service; | 
| 33 | 29 | import org.springframework.util.Assert; | 
| 34 | -import scala.Int; | |
| 35 | 30 | |
| 36 | -import javax.servlet.http.HttpServletResponse; | |
| 37 | -import java.sql.PreparedStatement; | |
| 38 | -import java.sql.ResultSet; | |
| 39 | -import java.sql.SQLException; | |
| 40 | 31 | import java.util.*; | 
| 41 | 32 | |
| 42 | 33 | /** | 
| ... | ... | @@ -50,6 +41,18 @@ | 
| 50 | 41 | @Autowired | 
| 51 | 42 | private MongoTemplate mongoTemplate; | 
| 52 | 43 | |
| 44 | + @Autowired | |
| 45 | + private DataPermissionService dataPermissionService; | |
| 46 | + | |
| 47 | + @Autowired | |
| 48 | + private AutoMatchFacade autoMatchFacade; | |
| 49 | + | |
| 50 | + @Autowired | |
| 51 | + private MongoUtil mongoUtil; | |
| 52 | + | |
| 53 | +// @Autowired | |
| 54 | + private UsersMapper usersMapper; | |
| 55 | + | |
| 53 | 56 | @Override | 
| 54 | 57 | public BaseObjectResponse init() { | 
| 55 | 58 | List<Map<String, Object>> feedType = EnumUtil.toJson(FeedTypeEnums.class); | 
| 56 | 59 | |
| 57 | 60 | |
| ... | ... | @@ -63,16 +66,113 @@ | 
| 63 | 66 | } | 
| 64 | 67 | |
| 65 | 68 | @Override | 
| 66 | - public BaseObjectResponse add(Integer userId, NewbornVisit newbornVisit) { | |
| 67 | - newbornVisit.setOperationId(userId.toString()); | |
| 68 | - newbornVisit.setCreated(new Date()); | |
| 69 | - newbornVisit.setYn("1"); | |
| 69 | + public BaseObjectResponse addOrUpdate(Integer userId, NewbornVisit newbornVisit) { | |
| 70 | 70 | newbornVisit.setFeedType(newbornVisit.getFeedType() == null ? null : FeedTypeEnums.get(Integer.parseInt(newbornVisit.getFeedType())).getName()); | 
| 71 | 71 | newbornVisit.setSkin(newbornVisit.getSkin() == null ? null : SkinEnums.get(Integer.parseInt(newbornVisit.getSkin())).getName()); | 
| 72 | - newbornVisit.setFeedType(newbornVisit.getFeedType() == null ? null : FeedTypeEnums.get(Integer.parseInt(newbornVisit.getFeedType())).getName()); | |
| 73 | - newbornVisit.setFeedType(newbornVisit.getFeedType() == null ? null : FeedTypeEnums.get(Integer.parseInt(newbornVisit.getFeedType())).getName()); | |
| 74 | - mongoTemplate.save(newbornVisit); | |
| 72 | + newbornVisit.setComplexion(newbornVisit.getComplexion() == null ? null : BregmaticEnums.get(Integer.parseInt(newbornVisit.getComplexion())).getName()); | |
| 73 | + newbornVisit.setUmbilicalCord(newbornVisit.getUmbilicalCord() == null ? null : UmbilicalCordEnums.get(Integer.parseInt(newbornVisit.getUmbilicalCord())).getName()); | |
| 74 | + newbornVisit.setHositalId(autoMatchFacade.getHospitalId(userId)); | |
| 75 | + // newbornVisit.setNextVisitTime(newbornVisit.getUmbilicalCord() == null ? null : UmbilicalCordEnums.get(Integer.parseInt(newbornVisit.getUmbilicalCord())).getName()); | |
| 76 | + if(StringUtils.isEmpty(newbornVisit.getId())) { | |
| 77 | + String babyId = null; | |
| 78 | + if(!buildArchive(userId, newbornVisit.getPid(), babyId)) { | |
| 79 | + return RespBuilder.buildSuccess(ResponseCode.NEED_BUILD); | |
| 80 | + } | |
| 81 | + newbornVisit.setBabyId(babyId); | |
| 82 | + newbornVisit.setId(UUID.randomUUID().toString().replace("-", "")); | |
| 83 | + newbornVisit.setOperationId(userId.toString()); | |
| 84 | + newbornVisit.setCreated(new Date()); | |
| 85 | + newbornVisit.setYn("1"); | |
| 86 | + mongoTemplate.save(newbornVisit); | |
| 87 | + } else { | |
| 88 | + newbornVisit.setId(UUID.randomUUID().toString().replace("-", "")); | |
| 89 | + newbornVisit.setOperationId(userId.toString()); | |
| 90 | + newbornVisit.setCreated(new Date()); | |
| 91 | + newbornVisit.setYn("1"); | |
| 92 | + Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(newbornVisit)); | |
| 93 | + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(newbornVisit.getId())), update, NewbornVisit.class); | |
| 94 | + | |
| 95 | + } | |
| 75 | 96 | return RespBuilder.buildSuccess(); | 
| 76 | 97 | } | 
| 98 | + | |
| 99 | + /** | |
| 100 | + * 隐藏建档 | |
| 101 | + * @param userId | |
| 102 | + * @return | |
| 103 | + */ | |
| 104 | + private boolean buildArchive(Integer userId, String pid, String babyId) { | |
| 105 | + Assert.notNull(pid, "pid 不能为null"); | |
| 106 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 107 | + // 如果本院已有记录 直接走正常流程 | |
| 108 | + BabyModel baby = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(pid).and("hospitalId").is(hospitalId)).with(new Sort(Sort.Direction.DESC, "created")), BabyModel.class); | |
| 109 | + if(baby != null) { | |
| 110 | + babyId = baby.getId(); | |
| 111 | + return true; | |
| 112 | + } | |
| 113 | + | |
| 114 | + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery(); | |
| 115 | + dataPermissionsModelQuery.setUserId(userId); | |
| 116 | + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery); | |
| 117 | + if (CollectionUtils.isNotEmpty(permissionsModels)) { | |
| 118 | + Set<String> set = permissionsModels.get(0).getData().keySet(); | |
| 119 | + Iterator<String> it = set.iterator(); | |
| 120 | + BabyModel babyModel = mongoTemplate.findOne(Query.query(Criteria.where("hospitalId").in(set) | |
| 121 | + .and("pid").is(pid)).with(new Sort(Sort.Direction.DESC, "created")), BabyModel.class); | |
| 122 | + if(babyModel == null) { | |
| 123 | + return false; // 需要建档 | |
| 124 | + } | |
| 125 | + babyId = UUID.randomUUID().toString().replace("-", ""); | |
| 126 | + babyModel.setId(babyId); | |
| 127 | + babyModel.setHospitalId(hospitalId); | |
| 128 | + babyModel.setEnable("2"); | |
| 129 | + babyModel.setCreated(new Date()); | |
| 130 | + mongoTemplate.save(babyModel); | |
| 131 | + return true; | |
| 132 | + } | |
| 133 | + return false; | |
| 134 | + } | |
| 135 | + | |
| 136 | + @Override | |
| 137 | + public BaseObjectResponse list(Date startDate, Date endDate, String doctor, Integer userId, String key, Integer page, Integer limit) { | |
| 138 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 139 | + Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").is(hospitalId); | |
| 140 | + if(startDate != null && endDate != null) { | |
| 141 | + criteria.and("checkTime").gte(startDate).lt(DateUtil.addDay(endDate, 1)); | |
| 142 | + } | |
| 143 | + if(StringUtils.isNotBlank(doctor)) { | |
| 144 | + criteria.and("doctor").is(doctor); | |
| 145 | + } | |
| 146 | + PageResult pageResult = findMongoPage(NewbornVisit.class, new Query(criteria), page, limit); | |
| 147 | + List<NewbornVisit> newbornVisits = (List<NewbornVisit>) pageResult.getGrid(); | |
| 148 | + List<Map<String, Object>> restMap = new ArrayList<>(); | |
| 149 | + for (NewbornVisit visit : newbornVisits) { | |
| 150 | + Map<String, Object> temp = new HashMap<>(); | |
| 151 | + | |
| 152 | + temp.put("checkTime", visit.getCheckTime() == null ? null : DateUtil.getyyyy_MM_dd(visit.getCheckTime())); // 复查访视时间 | |
| 153 | + String pid = visit.getPid(); | |
| 154 | + if(StringUtils.isNotBlank(pid)) { | |
| 155 | + PersonModel person = mongoTemplate.findById(pid, PersonModel.class); | |
| 156 | + if(person != null) { | |
| 157 | + temp.put("cardNo", person.getCardNo()); | |
| 158 | + temp.put("name", person.getName()); | |
| 159 | + temp.put("age", DateUtil.getAge(person.getBirth())); | |
| 160 | + temp.put("phone", person.getPhone()); | |
| 161 | + } | |
| 162 | + Patients patients = mongoTemplate.findById(visit.getParentId(), Patients.class); | |
| 163 | + if(patients != null) { | |
| 164 | + int days = DateUtil.daysBetween(patients.getFmDate(), new Date()); | |
| 165 | + temp.put("days", "产后"+days+"天"); | |
| 166 | + } | |
| 167 | + temp.put("count", mongoTemplate.count(new Query(criteria), NewbornVisit.class)); | |
| 168 | + temp.put("benyuan", mongoTemplate.count(new Query(criteria.and("visitHositalId").is(hospitalId)), NewbornVisit.class)); | |
| 169 | + Users users = usersMapper.getUsers(Integer.parseInt(visit.getDoctor())); | |
| 170 | + temp.put("doctorName", users == null ? null : users.getName()); | |
| 171 | + } | |
| 172 | + | |
| 173 | + } | |
| 174 | + return RespBuilder.buildSuccess(newbornVisits); | |
| 175 | + } | |
| 176 | + | |
| 77 | 177 | } |