Commit f8406a53e6a33a00cc31fdce71eb4310509e05b0
1 parent
f77750a8b3
Exists in
master
and in
6 other branches
新写电子病历接口
Showing 2 changed files with 496 additions and 2 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java
View file @
f8406a5
| ... | ... | @@ -1316,7 +1316,7 @@ |
| 1316 | 1316 | * @param list 同一产程记录 |
| 1317 | 1317 | * @param sortList 排序的结果 |
| 1318 | 1318 | */ |
| 1319 | - private void updateEditEnable(List<AntData> list, List<List<AntData>> sortList) { | |
| 1319 | + public static void updateEditEnable(List<AntData> list, List<List<AntData>> sortList) { | |
| 1320 | 1320 | //如果上个产程有数据,并且本产程有记录就设置上个产程不可编辑 |
| 1321 | 1321 | if (CollectionUtils.isNotEmpty(sortList) && CollectionUtils.isNotEmpty(list)) { |
| 1322 | 1322 | List<AntData> l = sortList.get(sortList.size() - 1); |
| ... | ... | @@ -1332,7 +1332,7 @@ |
| 1332 | 1332 | } |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | - private void sort(List<AntData> listData) { | |
| 1335 | + public static void sort(List<AntData> listData) { | |
| 1336 | 1336 | Collections.sort(listData, new Comparator<AntData>() { |
| 1337 | 1337 | @Override |
| 1338 | 1338 | public int compare(AntData o1, AntData o2) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientMedicalRecordFacade.java
View file @
f8406a5
| 1 | +package com.lyms.platform.operate.web.facade; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.*; | |
| 4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
| 5 | +import com.lyms.platform.common.enums.YnEnums; | |
| 6 | +import com.lyms.platform.common.result.BaseObjectResponse; | |
| 7 | +import com.lyms.platform.common.result.BaseResponse; | |
| 8 | +import com.lyms.platform.common.utils.DateUtil; | |
| 9 | +import com.lyms.platform.operate.web.request.AntExListQueryRequest; | |
| 10 | +import com.lyms.platform.operate.web.result.AntData; | |
| 11 | +import com.lyms.platform.operate.web.result.AntexListResult; | |
| 12 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 13 | +import com.lyms.platform.permission.model.Organization; | |
| 14 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 15 | +import com.lyms.platform.pojo.*; | |
| 16 | +import com.lyms.platform.query.*; | |
| 17 | +import org.apache.commons.collections.CollectionUtils; | |
| 18 | +import org.slf4j.Logger; | |
| 19 | +import org.slf4j.LoggerFactory; | |
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | +import org.springframework.data.domain.Sort; | |
| 22 | +import org.springframework.stereotype.Component; | |
| 23 | + | |
| 24 | +import java.util.*; | |
| 25 | + | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * 电子病历 | |
| 29 | + * <p/> | |
| 30 | + * 详细描述 | |
| 31 | + * <p/> | |
| 32 | + * 示例代码 | |
| 33 | + * <pre> | |
| 34 | + * </pre/> | |
| 35 | + * | |
| 36 | + * @author JIAZHI.JIANG | |
| 37 | + * @version BME V100R001 2018-02-08 11:56 | |
| 38 | + * @since BME V100R001C40B104 | |
| 39 | + */ | |
| 40 | +@Component | |
| 41 | +public class PatientMedicalRecordFacade { | |
| 42 | + | |
| 43 | + //日志调测器 | |
| 44 | + private static final Logger logger = LoggerFactory.getLogger(PatientMedicalRecordFacade.class); | |
| 45 | + | |
| 46 | + @Autowired | |
| 47 | + private OrganizationGroupsFacade groupsFacade; | |
| 48 | + @Autowired | |
| 49 | + private PatientsService patientsService; | |
| 50 | + @Autowired | |
| 51 | + private AutoMatchFacade autoMatchFacade; | |
| 52 | + @Autowired | |
| 53 | + private AntenatalExaminationFacade examinationFacade; | |
| 54 | + @Autowired | |
| 55 | + private OrganizationService organizationService; | |
| 56 | + | |
| 57 | + @Autowired | |
| 58 | + private AntenatalExaminationService antenatalExaminationService; | |
| 59 | + | |
| 60 | + @Autowired | |
| 61 | + private DischargeAbstractMotherService dischargeAbstractMotherService; | |
| 62 | + @Autowired | |
| 63 | + private PostReviewService postReviewService; | |
| 64 | + | |
| 65 | + @Autowired | |
| 66 | + private MatDeliverService matDeliverService; | |
| 67 | + | |
| 68 | + @Autowired | |
| 69 | + private StopPregnancyService stopPregnancyService; | |
| 70 | + | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 获取电子病历接口 | |
| 74 | + * | |
| 75 | + * @param exListQueryRequest 电子病历请求对象 | |
| 76 | + * @param userId 用户登录id | |
| 77 | + * @return 查询结果 | |
| 78 | + */ | |
| 79 | + public BaseResponse findAntExListTwo(AntExListQueryRequest exListQueryRequest, Integer userId) { | |
| 80 | + AntexListResult antexListResult = new AntexListResult(); | |
| 81 | + | |
| 82 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
| 83 | + patientsQuery.setCardNo(exListQueryRequest.getCardNo()); | |
| 84 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
| 85 | + patientsQuery.setPhone(exListQueryRequest.getPhone()); | |
| 86 | + patientsQuery.setPid(exListQueryRequest.getPid()); | |
| 87 | + patientsQuery.setBuildType(1); | |
| 88 | + //在区域组的时候不用查询隐藏档案 | |
| 89 | + if (null != groupsFacade.findByCurrentUserId(autoMatchFacade.getHospitalId(userId))) { | |
| 90 | + patientsQuery.setExtEnable(false); | |
| 91 | + } | |
| 92 | + | |
| 93 | + //获取所有的建档记录 | |
| 94 | + List<Patients> list = patientsService.queryPatient(patientsQuery); | |
| 95 | + | |
| 96 | + //处理电子病历的数据 | |
| 97 | + doExecuteMedicalRecord(antexListResult, userId, exListQueryRequest, list); | |
| 98 | + | |
| 99 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(antexListResult); | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 处理电子病历的数据 | |
| 104 | + * | |
| 105 | + * @param antexListResult | |
| 106 | + * @param userId | |
| 107 | + * @param exListQueryRequest | |
| 108 | + * @param list | |
| 109 | + */ | |
| 110 | + private void doExecuteMedicalRecord(AntexListResult antexListResult, Integer userId, AntExListQueryRequest exListQueryRequest, List<Patients> list) { | |
| 111 | + Patients patients2 = examinationFacade.findOnePatient(null, null, null, groupsFacade.findGroupHospital(userId, true), -1, true, exListQueryRequest.getPid(), false); | |
| 112 | + antexListResult.convertToResult(null, patients2, null); | |
| 113 | + List sortList = new ArrayList(); | |
| 114 | + | |
| 115 | + if (CollectionUtils.isNotEmpty(list)) { | |
| 116 | + HighScoreResult highScoreResult = examinationFacade.findLastRisk(list.get(0).getPid(), false); | |
| 117 | + antexListResult.setRiskFactor(highScoreResult.getHighRisk()); | |
| 118 | + antexListResult.setRiskScore(highScoreResult.getScoreStr()); | |
| 119 | + | |
| 120 | + //分组后的数据 | |
| 121 | + MedicalRecord medicalRecord = doHandMedicalRecordGroup(list); | |
| 122 | + | |
| 123 | + //处理已经分娩的电子病历数据 | |
| 124 | + if (CollectionUtils.isNotEmpty(medicalRecord.getFmPatient())) { | |
| 125 | + int size = medicalRecord.getFmPatient().size(); | |
| 126 | + for (int i = 0; i < size; i++) { | |
| 127 | + | |
| 128 | + MedicalRecordGroupVo medicalRecordGroupVo = medicalRecord.getFmPatient().get(i); | |
| 129 | + | |
| 130 | + List<AntData> listData = new ArrayList<AntData>(); | |
| 131 | + //处理分娩前的数据 | |
| 132 | + doHandBeforeFmRecord(medicalRecordGroupVo, listData); | |
| 133 | + //处理分娩后的数据 | |
| 134 | + doHandAfterFmRecord(medicalRecordGroupVo, listData, i + 1 == size ? new Date() : medicalRecord.getFmPatient().get(i).getMinLastMenses()); | |
| 135 | + //排序并修改按钮状态 | |
| 136 | + triggerAfterCompletion(listData, sortList); | |
| 137 | + } | |
| 138 | + } | |
| 139 | + | |
| 140 | + //处理未分娩的电子病历数据 | |
| 141 | + if (CollectionUtils.isNotEmpty(medicalRecord.getUfmPatient())) { | |
| 142 | + List<AntData> listData = new ArrayList<AntData>(); | |
| 143 | + for (MedicalRecordGroupVo medicalRecordGroupVo : medicalRecord.getUfmPatient()) { | |
| 144 | + //处理分娩前的数据 | |
| 145 | + doHandBeforeFmRecord(medicalRecordGroupVo, listData); | |
| 146 | + } | |
| 147 | + //排序并修改按钮状态 | |
| 148 | + triggerAfterCompletion(listData, sortList); | |
| 149 | + } | |
| 150 | + } | |
| 151 | + antexListResult.setData(sortList); | |
| 152 | + } | |
| 153 | + | |
| 154 | + /** | |
| 155 | + * 排序并修改按钮状态 | |
| 156 | + * | |
| 157 | + * @param listData 一个产程的数据 | |
| 158 | + * @param sortList 多个产程的数据集合 | |
| 159 | + */ | |
| 160 | + private void triggerAfterCompletion(List<AntData> listData, List sortList) { | |
| 161 | + //排序并修改按钮状态 | |
| 162 | + AntenatalExaminationFacade.sort(listData); | |
| 163 | + AntenatalExaminationFacade.updateEditEnable(listData, sortList); | |
| 164 | + sortList.add(listData); | |
| 165 | + } | |
| 166 | + | |
| 167 | + /** | |
| 168 | + * 处理分娩后的数据 | |
| 169 | + * | |
| 170 | + * @param medicalRecordGroupVo | |
| 171 | + * @param listData | |
| 172 | + */ | |
| 173 | + private void doHandAfterFmRecord(MedicalRecordGroupVo medicalRecordGroupVo, List<AntData> listData, Date nextLastMenses) { | |
| 174 | + PostReviewQuery postReviewQuery = new PostReviewQuery(); | |
| 175 | + String pid = medicalRecordGroupVo.getPid(); | |
| 176 | + postReviewQuery.setStart(medicalRecordGroupVo.getFmDate()); | |
| 177 | + //下次建档记录前都是产后复查,如果没有下个产程的数据就直接显示 | |
| 178 | + postReviewQuery.setEnd(nextLastMenses); | |
| 179 | + postReviewQuery.setPid(pid); | |
| 180 | + Organization organization = null; | |
| 181 | + | |
| 182 | + | |
| 183 | + MatDeliverQuery matDeliverQuery = new MatDeliverQuery(); | |
| 184 | + matDeliverQuery.setPid(medicalRecordGroupVo.getPid()); | |
| 185 | + matDeliverQuery.setYn(YnEnums.YES.getId()); | |
| 186 | + matDeliverQuery.setCreatedStart(medicalRecordGroupVo.getFmDate()); | |
| 187 | + matDeliverQuery.setEndStart(nextLastMenses); | |
| 188 | + List<MaternalDeliverModel> metDel = matDeliverService.query(matDeliverQuery); | |
| 189 | + | |
| 190 | + if (CollectionUtils.isNotEmpty(metDel)) { | |
| 191 | + MaternalDeliverModel model = metDel.get(0); | |
| 192 | + if (null != model.getHospitalId()) { | |
| 193 | + organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId())); | |
| 194 | + } | |
| 195 | + listData.add(new AntData(model, medicalRecordGroupVo.getMinLastMenses(), null != organization ? organization.getName() : "")); | |
| 196 | + } else { | |
| 197 | + StopPregQuery query = new StopPregQuery(); | |
| 198 | + query.setYn(YnEnums.YES.getId()); | |
| 199 | + query.setPid(medicalRecordGroupVo.getPid()); | |
| 200 | + query.setStopDateStart(medicalRecordGroupVo.getFmDate()); | |
| 201 | + query.setStopDateEnd(nextLastMenses); | |
| 202 | + List<StopPregModel> stopPregs = stopPregnancyService.queryStopPreg(query); | |
| 203 | + if (CollectionUtils.isNotEmpty(stopPregs)) { | |
| 204 | + StopPregModel model = stopPregs.get(0); | |
| 205 | + if (null != model.getHospitalId()) { | |
| 206 | + organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId())); | |
| 207 | + } | |
| 208 | + listData.add(new AntData(model, medicalRecordGroupVo.getMinLastMenses(), null != organization ? organization.getName() : "")); | |
| 209 | + } | |
| 210 | + } | |
| 211 | + | |
| 212 | + | |
| 213 | + DischargeAbstractMotherQuery dischargeAbstractMotherQuery = new DischargeAbstractMotherQuery(); | |
| 214 | + dischargeAbstractMotherQuery.setPid(pid); | |
| 215 | + dischargeAbstractMotherQuery.setYn(YnEnums.YES.getId()); | |
| 216 | + dischargeAbstractMotherQuery.setStart(medicalRecordGroupVo.getFmDate()); | |
| 217 | + dischargeAbstractMotherQuery.setEnd(nextLastMenses); | |
| 218 | + | |
| 219 | + List<DischargeAbstractMotherModel> dischargeAbstractMotherModels = dischargeAbstractMotherService.query(dischargeAbstractMotherQuery); | |
| 220 | + | |
| 221 | + if (CollectionUtils.isNotEmpty(dischargeAbstractMotherModels)) { | |
| 222 | + for (DischargeAbstractMotherModel model : dischargeAbstractMotherModels) { | |
| 223 | + listData.add(new AntData(model, null != organization ? organization.getName() : "", medicalRecordGroupVo.getFmDate())); | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + | |
| 228 | + //产后复查记录 | |
| 229 | + List<PostReviewModel> reviewModels = postReviewService.findWithList(postReviewQuery); | |
| 230 | + if (CollectionUtils.isNotEmpty(reviewModels)) { | |
| 231 | + for (PostReviewModel postReviewModel : reviewModels) { | |
| 232 | + if (postReviewModel.getYn() == YnEnums.YES.getId()) { | |
| 233 | + if (null != postReviewModel.getHospitalId()) { | |
| 234 | + organization = organizationService.getOrganization(Integer.valueOf(postReviewModel.getHospitalId())); | |
| 235 | + } | |
| 236 | + listData.add(new AntData(postReviewModel, null != organization ? organization.getName() : "", medicalRecordGroupVo.getFmDate())); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + } | |
| 240 | + } | |
| 241 | + | |
| 242 | + /** | |
| 243 | + * 处理分娩前的数据 | |
| 244 | + * | |
| 245 | + * @param medicalRecordGroupVo | |
| 246 | + * @param listData | |
| 247 | + * @return | |
| 248 | + */ | |
| 249 | + private List doHandBeforeFmRecord(MedicalRecordGroupVo medicalRecordGroupVo, List<AntData> listData) { | |
| 250 | + | |
| 251 | + Organization organization = null; | |
| 252 | + String pid = ""; | |
| 253 | + | |
| 254 | + for (String patientId : medicalRecordGroupVo.getPatientIds()) { | |
| 255 | + | |
| 256 | + Patients patients = patientsService.findOnePatientById(patientId); | |
| 257 | + //建档记录 | |
| 258 | + if (null != patients.getHospitalId()) { | |
| 259 | + organization = organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())); | |
| 260 | + } | |
| 261 | + pid = patients.getPid(); | |
| 262 | + if (!"2".equals(patients.getEnable())) { | |
| 263 | + listData.add(new AntData(patients, null != organization ? organization.getName() : "")); | |
| 264 | + } | |
| 265 | + } | |
| 266 | + | |
| 267 | + | |
| 268 | + //初诊记录 | |
| 269 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
| 270 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 271 | + antExChuQuery.setStart(medicalRecordGroupVo.getMinLastMenses()); | |
| 272 | + antExChuQuery.setEnd(medicalRecordGroupVo.getFmDate()); | |
| 273 | + antExChuQuery.setPid(pid); | |
| 274 | + | |
| 275 | + List<AntExChuModel> antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery); | |
| 276 | + if (CollectionUtils.isNotEmpty(antExChuModels)) { | |
| 277 | + for (AntExChuModel an : antExChuModels) { | |
| 278 | + if (null != an.getHospitalId()) { | |
| 279 | + organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId())); | |
| 280 | + } | |
| 281 | + listData.add(new AntData(an, null != organization ? organization.getName() : "", medicalRecordGroupVo.getMinLastMenses())); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + | |
| 285 | + //复诊记录 | |
| 286 | + AntExQuery antExQuery = new AntExQuery(); | |
| 287 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 288 | + antExQuery.setPid(pid); | |
| 289 | + antExQuery.setStart(medicalRecordGroupVo.getMinLastMenses()); | |
| 290 | + antExQuery.setEnd(medicalRecordGroupVo.getFmDate()); | |
| 291 | + | |
| 292 | + List<AntenatalExaminationModel> list1 = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); | |
| 293 | + if (CollectionUtils.isNotEmpty(list1)) { | |
| 294 | + for (AntenatalExaminationModel an : list1) { | |
| 295 | + if (null != an.getHospitalId()) { | |
| 296 | + organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId())); | |
| 297 | + } | |
| 298 | + listData.add(new AntData(an, null != organization ? organization.getName() : "", medicalRecordGroupVo.getMinLastMenses())); | |
| 299 | + } | |
| 300 | + } | |
| 301 | + return listData; | |
| 302 | + } | |
| 303 | + | |
| 304 | + /** | |
| 305 | + * 把建档的数据按分娩日期进行分组 | |
| 306 | + * | |
| 307 | + * @param patientses | |
| 308 | + * @return | |
| 309 | + */ | |
| 310 | + private MedicalRecord doHandMedicalRecordGroup(List<Patients> patientses) { | |
| 311 | + Map<String, MedicalRecordGroupVo> patientGroup = new HashMap<>(); | |
| 312 | + List<MedicalRecordGroupVo> groupVoList = new ArrayList<>(); | |
| 313 | + MedicalRecordGroupVo recordGroupVo = null; | |
| 314 | + for (Patients patients : patientses) { | |
| 315 | + //已分娩的 | |
| 316 | + if (patients.getType() == 3) { | |
| 317 | + String mapkey = DateUtil.getyyyy_MM_dd(patients.getFmDate()); | |
| 318 | + //未分娩的 | |
| 319 | + if (patientGroup.containsKey(mapkey)) { | |
| 320 | + MedicalRecordGroupVo medicalRecordGroupVo = patientGroup.get(mapkey); | |
| 321 | + medicalRecordGroupVo.getPatientIds().add(patients.getId()); | |
| 322 | + medicalRecordGroupVo.setMinLastMenses(patients.getLastMenses()); | |
| 323 | + medicalRecordGroupVo.setPid(patients.getPid()); | |
| 324 | + } else { | |
| 325 | + List<String> patientId = new ArrayList<>(); | |
| 326 | + patientId.add(patients.getId()); | |
| 327 | + MedicalRecordGroupVo medicalRecordGroupVo = new MedicalRecordGroupVo(patients.getFmDate(), patients.getLastMenses(), patientId, patients.getPid()); | |
| 328 | + patientGroup.put(mapkey, medicalRecordGroupVo); | |
| 329 | + } | |
| 330 | + } else if (patients.getType() == 1) { | |
| 331 | + List<String> patientId = new ArrayList<>(); | |
| 332 | + patientId.add(patients.getId()); | |
| 333 | + if (null == recordGroupVo) { | |
| 334 | + recordGroupVo = new MedicalRecordGroupVo(patients.getFmDate(), patients.getLastMenses(), patientId, patients.getPid()); | |
| 335 | + } else { | |
| 336 | + recordGroupVo.getPatientIds().add(patients.getId()); | |
| 337 | + recordGroupVo.setMinLastMenses(patients.getLastMenses()); | |
| 338 | + recordGroupVo.setPid(patients.getPid()); | |
| 339 | + } | |
| 340 | + } | |
| 341 | + } | |
| 342 | + | |
| 343 | + if (null != recordGroupVo) { | |
| 344 | + groupVoList.add(recordGroupVo); | |
| 345 | + } | |
| 346 | + | |
| 347 | + sort(groupVoList, Boolean.TRUE); | |
| 348 | + return new MedicalRecord(toListAndSort(patientGroup), groupVoList); | |
| 349 | + } | |
| 350 | + | |
| 351 | + /** | |
| 352 | + * 把分组后的数据转成集合并排序 | |
| 353 | + * | |
| 354 | + * @param patientGroup | |
| 355 | + * @return | |
| 356 | + */ | |
| 357 | + private List<MedicalRecordGroupVo> toListAndSort(Map<String, MedicalRecordGroupVo> patientGroup) { | |
| 358 | + Set<Map.Entry<String, MedicalRecordGroupVo>> medicalRecordGroupVoSet = patientGroup.entrySet(); | |
| 359 | + Iterator<Map.Entry<String, MedicalRecordGroupVo>> IT = medicalRecordGroupVoSet.iterator(); | |
| 360 | + List<MedicalRecordGroupVo> DATA = new ArrayList<>(); | |
| 361 | + | |
| 362 | + while (IT.hasNext()) { | |
| 363 | + DATA.add(IT.next().getValue()); | |
| 364 | + } | |
| 365 | + sort(DATA, Boolean.FALSE); | |
| 366 | + return DATA; | |
| 367 | + } | |
| 368 | + | |
| 369 | + /** | |
| 370 | + * @param DATA | |
| 371 | + * @param fmNull 分娩时间是否为空 TRUE/FALSE | |
| 372 | + */ | |
| 373 | + private void sort(List<MedicalRecordGroupVo> DATA, boolean fmNull) { | |
| 374 | + Comparator comparator = null; | |
| 375 | + | |
| 376 | + | |
| 377 | + if (fmNull) { | |
| 378 | + comparator = new Comparator<MedicalRecordGroupVo>() { | |
| 379 | + @Override | |
| 380 | + public int compare(MedicalRecordGroupVo o1, MedicalRecordGroupVo o2) { | |
| 381 | + if (o1.getMinLastMenses() != null && null != o2.getMinLastMenses() && o1.getMinLastMenses().after(o2.getMinLastMenses())) { | |
| 382 | + return -1; | |
| 383 | + } | |
| 384 | + if (o1.getMinLastMenses() != null && null != o2.getMinLastMenses() && o1.getMinLastMenses().before(o2.getMinLastMenses())) { | |
| 385 | + return 1; | |
| 386 | + } | |
| 387 | + return 0; | |
| 388 | + } | |
| 389 | + }; | |
| 390 | + } else { | |
| 391 | + comparator = new Comparator<MedicalRecordGroupVo>() { | |
| 392 | + @Override | |
| 393 | + public int compare(MedicalRecordGroupVo o1, MedicalRecordGroupVo o2) { | |
| 394 | + if (o1.getFmDate() != null && null != o2.getFmDate() && o1.getFmDate().after(o2.getFmDate())) { | |
| 395 | + return -1; | |
| 396 | + } | |
| 397 | + if (o1.getFmDate() != null && null != o2.getFmDate() && o1.getFmDate().before(o2.getFmDate())) { | |
| 398 | + return 1; | |
| 399 | + } | |
| 400 | + return 0; | |
| 401 | + } | |
| 402 | + }; | |
| 403 | + } | |
| 404 | + //按照数据排序 | |
| 405 | + Collections.sort(DATA, comparator); | |
| 406 | + } | |
| 407 | + | |
| 408 | + | |
| 409 | + private class MedicalRecord { | |
| 410 | + //已分娩的建档数据 | |
| 411 | + private List<MedicalRecordGroupVo> fmPatient; | |
| 412 | + //未分娩的建档数据 | |
| 413 | + private List<MedicalRecordGroupVo> ufmPatient; | |
| 414 | + | |
| 415 | + | |
| 416 | + public MedicalRecord(List<MedicalRecordGroupVo> fmPatient, List<MedicalRecordGroupVo> ufmPatient) { | |
| 417 | + this.fmPatient = fmPatient; | |
| 418 | + this.ufmPatient = ufmPatient; | |
| 419 | + } | |
| 420 | + | |
| 421 | + public List<MedicalRecordGroupVo> getFmPatient() { | |
| 422 | + return fmPatient; | |
| 423 | + } | |
| 424 | + | |
| 425 | + public void setFmPatient(List<MedicalRecordGroupVo> fmPatient) { | |
| 426 | + this.fmPatient = fmPatient; | |
| 427 | + } | |
| 428 | + | |
| 429 | + public List<MedicalRecordGroupVo> getUfmPatient() { | |
| 430 | + return ufmPatient; | |
| 431 | + } | |
| 432 | + | |
| 433 | + public void setUfmPatient(List<MedicalRecordGroupVo> ufmPatient) { | |
| 434 | + this.ufmPatient = ufmPatient; | |
| 435 | + } | |
| 436 | + } | |
| 437 | + | |
| 438 | + /** | |
| 439 | + * 病历分组对象 | |
| 440 | + */ | |
| 441 | + private class MedicalRecordGroupVo { | |
| 442 | + //分娩时间 | |
| 443 | + private Date fmDate; | |
| 444 | + //这个产程里面最早的一个末次月经时间 | |
| 445 | + private Date minLastMenses; | |
| 446 | + //孕妇建档id | |
| 447 | + private List<String> patientIds; | |
| 448 | + | |
| 449 | + private String pid; | |
| 450 | + | |
| 451 | + public MedicalRecordGroupVo(Date fmDate, Date minLastMenses, List<String> patientIds, String pid) { | |
| 452 | + this.fmDate = fmDate; | |
| 453 | + this.minLastMenses = minLastMenses; | |
| 454 | + this.patientIds = patientIds; | |
| 455 | + this.pid = pid; | |
| 456 | + } | |
| 457 | + | |
| 458 | + public String getPid() { | |
| 459 | + return pid; | |
| 460 | + } | |
| 461 | + | |
| 462 | + public void setPid(String pid) { | |
| 463 | + if (null != pid) { | |
| 464 | + this.pid = pid; | |
| 465 | + } | |
| 466 | + } | |
| 467 | + | |
| 468 | + public Date getFmDate() { | |
| 469 | + return fmDate; | |
| 470 | + } | |
| 471 | + | |
| 472 | + public void setFmDate(Date fmDate) { | |
| 473 | + this.fmDate = fmDate; | |
| 474 | + } | |
| 475 | + | |
| 476 | + public Date getMinLastMenses() { | |
| 477 | + return minLastMenses; | |
| 478 | + } | |
| 479 | + | |
| 480 | + public void setMinLastMenses(Date minLastMenses) { | |
| 481 | + if (minLastMenses.getTime() < this.minLastMenses.getTime()) { | |
| 482 | + this.minLastMenses = minLastMenses; | |
| 483 | + } | |
| 484 | + } | |
| 485 | + | |
| 486 | + public List<String> getPatientIds() { | |
| 487 | + return patientIds; | |
| 488 | + } | |
| 489 | + | |
| 490 | + public void setPatientIds(List<String> patientIds) { | |
| 491 | + this.patientIds = patientIds; | |
| 492 | + } | |
| 493 | + } | |
| 494 | +} |