Commit b0b6c173cf3160a88a98aa23cdd82442f5a0b953
1 parent
e2c36b0679
Exists in
master
and in
8 other branches
儿童建档
Showing 6 changed files with 138 additions and 47 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientDao.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientDaoImpl.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java
- platform-dal/src/main/java/com/lyms/platform/query/PersonModelQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java
View file @
b0b6c17
| ... | ... | @@ -136,14 +136,14 @@ |
| 136 | 136 | service.addVisit(visitModel) |
| 137 | 137 | ; } |
| 138 | 138 | public static void addBaby(ApplicationContext applicationContext){ |
| 139 | - BabyModel babyModel = new BabyModel(); | |
| 140 | - babyModel.setBirth(new Date()); | |
| 141 | - babyModel.setName("小孩的名字"); | |
| 142 | - babyModel.setSex(1); | |
| 143 | - babyModel.setVisitstatus(1); | |
| 144 | - babyModel.setParentId("56ebbff424fdd5ddf5dd2070"); | |
| 145 | - BabyService babyService = applicationContext.getBean(BabyService.class); | |
| 146 | - babyService.addOneBaby(babyModel); | |
| 139 | +// BabyModel babyModel = new BabyModel(); | |
| 140 | +// babyModel.setBirth(new Date()); | |
| 141 | +// babyModel.setName("小孩的名字"); | |
| 142 | +// babyModel.setSex(1); | |
| 143 | +// babyModel.setVisitstatus(1); | |
| 144 | +// babyModel.setParentId("56ebbff424fdd5ddf5dd2070"); | |
| 145 | +// BabyService babyService = applicationContext.getBean(BabyService.class); | |
| 146 | +// babyService.addOneBaby(babyModel); | |
| 147 | 147 | ; } |
| 148 | 148 | } |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientDao.java
View file @
b0b6c17
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientDaoImpl.java
View file @
b0b6c17
| ... | ... | @@ -6,8 +6,14 @@ |
| 6 | 6 | import com.lyms.platform.common.dao.operator.MongoOper; |
| 7 | 7 | import com.lyms.platform.common.dao.operator.MongoQuery; |
| 8 | 8 | import com.lyms.platform.common.dao.operator.Page; |
| 9 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 9 | 10 | import com.lyms.platform.pojo.Patients; |
| 10 | 11 | import org.bson.types.ObjectId; |
| 12 | +import org.springframework.data.mongodb.core.aggregation.Aggregation; | |
| 13 | +import org.springframework.data.mongodb.core.aggregation.AggregationOperation; | |
| 14 | +import org.springframework.data.mongodb.core.aggregation.AggregationResults; | |
| 15 | +import org.springframework.data.mongodb.core.aggregation.Field; | |
| 16 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 11 | 17 | import org.springframework.stereotype.Repository; |
| 12 | 18 | |
| 13 | 19 | import java.util.List; |
| ... | ... | @@ -56,6 +62,21 @@ |
| 56 | 62 | @Override |
| 57 | 63 | public Page<Patients> findPage(MongoQuery query) { |
| 58 | 64 | return findPage(query.convertToMongoQuery()); |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public Patients findLastBuildRecord(String pid, int yn) { | |
| 69 | + AggregationOperation match = Aggregation.match(Criteria.where("pid").is(pid).and("yn").is(yn)); | |
| 70 | + AggregationOperation group = Aggregation.group("_id","pid","dueDate").max("created").as("created"); | |
| 71 | + AggregationOperation fields = Aggregation.project("_id", "pid", "dueDate"); | |
| 72 | + Aggregation aggregation = Aggregation.newAggregation(match, group,fields); | |
| 73 | + AggregationResults<Patients> result = this.mongoTemplate.aggregate(aggregation, "lyms_patient", Patients.class); | |
| 74 | + return result.getMappedResults().size() > 0 ? result.getMappedResults().get(0) : null; | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Override | |
| 78 | + public void updatePatientByPid(Patients obj, String pid) { | |
| 79 | + update(new MongoQuery(new MongoCondition("pid", pid, MongoOper.IS)).convertToMongoQuery(), obj); | |
| 59 | 80 | } |
| 60 | 81 | } |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientsService.java
View file @
b0b6c17
| ... | ... | @@ -172,6 +172,14 @@ |
| 172 | 172 | return sieveModel; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | + public Patients findLastBuildRecord(String pid, int yn) { | |
| 176 | + return iPatientDao.findLastBuildRecord(pid,yn); | |
| 177 | + } | |
| 178 | + | |
| 179 | + public void updatePatientByPid(Patients patientUpdate, String pid) { | |
| 180 | + iPatientDao.updatePatientByPid(patientUpdate,pid); | |
| 181 | + } | |
| 182 | + | |
| 175 | 183 | private class PatientWorker extends Thread { |
| 176 | 184 | private List<Patients> patientses; |
| 177 | 185 | private long startTime; |
platform-dal/src/main/java/com/lyms/platform/query/PersonModelQuery.java
View file @
b0b6c17
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | |
| 34 | 34 | //类型 1 孕妇 2 儿童 3孕妇 |
| 35 | 35 | private Integer type; |
| 36 | + private Integer[] types; | |
| 36 | 37 | |
| 37 | 38 | private Date created; |
| 38 | 39 | |
| 39 | 40 | |
| ... | ... | @@ -61,8 +62,21 @@ |
| 61 | 62 | if (type != null) { |
| 62 | 63 | condition = condition.and("type", type, MongoOper.IS); |
| 63 | 64 | } |
| 65 | + if (types != null && types.length == 2) { | |
| 66 | + Criteria c = Criteria.where("type").in(types[0],types[1]); | |
| 67 | + return new MongoCondition(condition.getCriteria().andOperator(c)).toMongoQuery(); | |
| 68 | + } | |
| 64 | 69 | |
| 65 | 70 | return condition.toMongoQuery(); |
| 71 | + } | |
| 72 | + | |
| 73 | + | |
| 74 | + public Integer[] getTypes() { | |
| 75 | + return types; | |
| 76 | + } | |
| 77 | + | |
| 78 | + public void setTypes(Integer[] types) { | |
| 79 | + this.types = types; | |
| 66 | 80 | } |
| 67 | 81 | |
| 68 | 82 | public String getId() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
View file @
b0b6c17
| ... | ... | @@ -164,6 +164,9 @@ |
| 164 | 164 | */ |
| 165 | 165 | public BaseObjectResponse addBabyBookbuilding(BabyBookbuildingAddRequest request) { |
| 166 | 166 | |
| 167 | + | |
| 168 | +// Patients ppatients = patientsService.findLastBuildRecord("579b15d1231a17fcf5579bec",YnEnums.YES.getId()); | |
| 169 | +// return null; | |
| 167 | 170 | //判断儿童是否建档在该医院 |
| 168 | 171 | if (StringUtils.isNotEmpty(request.getMommyPhone()) || StringUtils.isNotEmpty(request.getMommyCertificateNum())) |
| 169 | 172 | { |
| 170 | 173 | |
| 171 | 174 | |
| 172 | 175 | |
| ... | ... | @@ -187,49 +190,20 @@ |
| 187 | 190 | } |
| 188 | 191 | } |
| 189 | 192 | |
| 190 | - | |
| 191 | - //通过查询是否有该孕妇 | |
| 192 | - PatientsQuery puerperaQuery = new PatientsQuery(); | |
| 193 | - puerperaQuery.setCardNo(request.getMommyCertificateNum()); | |
| 194 | - puerperaQuery.setYn(YnEnums.YES.getId()); | |
| 195 | - Patients patients = patientsService.findOnePatientByCardNo(puerperaQuery); | |
| 196 | - | |
| 197 | - if (patients != null) { | |
| 198 | - if (patients.getType() == 1) { | |
| 199 | - | |
| 200 | - //判断在儿童建档的时候,是否设置到这个儿童对应的孕妇 设置成产妇 | |
| 201 | - //计算规则 儿童生日 > 孕妇分娩时间 - 60 设置成分娩 | |
| 202 | - Date dueDate = patients.getDueDate(); | |
| 203 | - if (dueDate != null && request.getBabyBirthday() != null) { | |
| 204 | - Date brith = DateUtil.parseYMD(request.getBabyBirthday()); | |
| 205 | - Date tempDate = DateUtil.addDay(dueDate, -60); | |
| 206 | - if (brith.getTime() > tempDate.getTime()) { | |
| 207 | - //设置孕妇已分娩 | |
| 208 | - Patients patientUpdate = new Patients(); | |
| 209 | - patientUpdate.setId(patients.getId()); | |
| 210 | - patientUpdate.setYn(YnEnums.YES.getId()); | |
| 211 | - patientUpdate.setType(3); | |
| 212 | - patientsService.updatePatient(patientUpdate); | |
| 213 | - } | |
| 214 | - } | |
| 215 | - | |
| 216 | - } | |
| 217 | - | |
| 218 | - } else { | |
| 219 | - //添加产妇建档 | |
| 220 | - Patients patient = getPatientsData(request); | |
| 221 | - patient.setCreated(new Date()); | |
| 222 | - patients = yunBookbuildingService.addPregnantBookbuilding(patient); | |
| 223 | - } | |
| 224 | - | |
| 225 | - | |
| 193 | + Patients patients = null; | |
| 226 | 194 | PersonModel resperson = null; |
| 227 | 195 | if (request.getMommyPhone() != null || request.getMommyCertificateNum() != null) |
| 228 | 196 | { |
| 197 | + //查询儿童基本信息 | |
| 229 | 198 | PersonModelQuery personModelQuery = new PersonModelQuery(); |
| 230 | 199 | personModelQuery.setPhone(request.getMommyPhone()); |
| 231 | 200 | personModelQuery.setYn(YnEnums.YES.getId()); |
| 201 | + personModelQuery.setName(request.getBabyName()); | |
| 202 | + personModelQuery.setType(2); | |
| 203 | + personModelQuery.setCardNo(request.getMommyCertificateNum()); | |
| 232 | 204 | List<PersonModel> personModels = personService.queryPersons(personModelQuery); |
| 205 | + | |
| 206 | + //更新儿童基本信息的内容 | |
| 233 | 207 | PersonModel pmodel = new PersonModel(); |
| 234 | 208 | pmodel.setName(request.getBabyName()); |
| 235 | 209 | pmodel.setBirth(DateUtil.parseYMD(request.getBabyBirthday())); |
| ... | ... | @@ -240,7 +214,6 @@ |
| 240 | 214 | pmodel.setModified(new Date()); |
| 241 | 215 | if (CollectionUtils.isNotEmpty(personModels) && personModels.get(0) != null) |
| 242 | 216 | { |
| 243 | - | |
| 244 | 217 | resperson = personModels.get(0); |
| 245 | 218 | personService.updatePerson(pmodel,personModels.get(0).getId()); |
| 246 | 219 | } |
| 247 | 220 | |
| ... | ... | @@ -253,7 +226,75 @@ |
| 253 | 226 | } |
| 254 | 227 | |
| 255 | 228 | |
| 229 | + //查询孕妇或者产妇建档的基本信息 | |
| 230 | + PersonModelQuery personYunModelQuery = new PersonModelQuery(); | |
| 231 | + personYunModelQuery.setPhone(request.getMommyPhone()); | |
| 232 | + personYunModelQuery.setYn(YnEnums.YES.getId()); | |
| 233 | + personYunModelQuery.setTypes(new Integer[]{1, 3}); | |
| 234 | + personYunModelQuery.setCardNo(request.getMommyCertificateNum()); | |
| 235 | + List<PersonModel> personYunModels = personService.queryPersons(personYunModelQuery); | |
| 236 | + if (CollectionUtils.isNotEmpty(personYunModels)) | |
| 237 | + { | |
| 238 | + PersonModel pm = personYunModels.get(0); | |
| 239 | + if (pm != null) | |
| 240 | + { | |
| 241 | + //查询最后一次建档记录 | |
| 242 | + patients = patientsService.findLastBuildRecord(pm.getId(),YnEnums.YES.getId()); | |
| 243 | + //当前状态为 孕妇状态 | |
| 244 | + if (pm.getType() != null && pm.getType() == 1) | |
| 245 | + { | |
| 256 | 246 | |
| 247 | + if (patients != null) { | |
| 248 | + if (patients.getType() == 1) { | |
| 249 | + | |
| 250 | + //判断在儿童建档的时候,是否设置到这个儿童对应的孕妇 设置成产妇 | |
| 251 | + //计算规则 儿童生日 > 孕妇分娩时间 - 60 设置成分娩 | |
| 252 | + Date dueDate = patients.getDueDate(); | |
| 253 | + if (dueDate != null && request.getBabyBirthday() != null) { | |
| 254 | + Date brith = DateUtil.parseYMD(request.getBabyBirthday()); | |
| 255 | + Date tempDate = DateUtil.addDay(dueDate, -60); | |
| 256 | + if (brith.getTime() > tempDate.getTime()) { | |
| 257 | + //设置孕妇已分娩 | |
| 258 | + Patients patientUpdate = new Patients(); | |
| 259 | + patientUpdate.setYn(YnEnums.YES.getId()); | |
| 260 | + patientUpdate.setType(3); | |
| 261 | + patientsService.updatePatientByPid(patientUpdate,pm.getId()); | |
| 262 | + | |
| 263 | + | |
| 264 | + pm.setType(3);//基本信息更新成产妇 | |
| 265 | + resperson = pm; | |
| 266 | + personService.updatePerson(pm,pm.getId()); | |
| 267 | + } | |
| 268 | + } | |
| 269 | + } | |
| 270 | + } | |
| 271 | + } | |
| 272 | + } | |
| 273 | + } | |
| 274 | + //没有孕妇基本信息就新建产妇建档 和基本信息 | |
| 275 | + else | |
| 276 | + { | |
| 277 | + //添加产妇基本信息 | |
| 278 | + PersonModel pmodel = new PersonModel(); | |
| 279 | + pmodel.setName(request.getMommyName()); | |
| 280 | + pmodel.setBirth(DateUtil.parseYMD(request.getMommyBirthday())); | |
| 281 | + pmodel.setPhone(request.getMommyPhone()); | |
| 282 | + pmodel.setCardNo(request.getMommyCertificateNum()); | |
| 283 | + pmodel.setType(3); | |
| 284 | + pmodel.setYn(YnEnums.YES.getId()); | |
| 285 | + pmodel.setModified(new Date()); | |
| 286 | + pmodel.setCreated(new Date()); | |
| 287 | + | |
| 288 | + PersonModel yunModel = personService.addPerson(pmodel); | |
| 289 | + | |
| 290 | + //添加产妇建档 | |
| 291 | + Patients patient = getPatientsData(request); | |
| 292 | + patient.setPid(yunModel.getId()); | |
| 293 | + patient.setCreated(new Date()); | |
| 294 | + patients = yunBookbuildingService.addPregnantBookbuilding(patient); | |
| 295 | + } | |
| 296 | + | |
| 297 | + | |
| 257 | 298 | BabyModel model = getBabyModel(request); |
| 258 | 299 | model.setPid(resperson.getId()); |
| 259 | 300 | |
| ... | ... | @@ -261,7 +302,6 @@ |
| 261 | 302 | |
| 262 | 303 | String cardId = request.getMommyCertificateNum() + |
| 263 | 304 | DateUtil.getYmd(DateUtil.parseYMD(request.getBabyBirthday())); |
| 264 | - //count = babyBookbuildingService.queryBabyCount(babyQuery); | |
| 265 | 305 | model.setCardId(cardId + request.getBabyName()); |
| 266 | 306 | } |
| 267 | 307 | if (StringUtils.isNotEmpty(request.getMommyPhone())) |
| ... | ... | @@ -271,7 +311,10 @@ |
| 271 | 311 | model.setPhoneId(phoneId + request.getBabyName()); |
| 272 | 312 | } |
| 273 | 313 | |
| 274 | - model.setParentId(patients.getId()); | |
| 314 | + if (patients.getId() != null) | |
| 315 | + { | |
| 316 | + model.setParentId(patients.getId()); | |
| 317 | + } | |
| 275 | 318 | model.setCreated(new Date()); |
| 276 | 319 | model.setModified(new Date()); |
| 277 | 320 | model = babyBookbuildingService.addBabyBookbuilding(model); |
| ... | ... | @@ -289,6 +332,7 @@ |
| 289 | 332 | br.setData(model.getId()); |
| 290 | 333 | |
| 291 | 334 | return br; |
| 335 | + | |
| 292 | 336 | } |
| 293 | 337 | |
| 294 | 338 |