Commit 555860c36c83ab466b7713a60c676877fa023d96

Authored by yangfei
1 parent d5f62e902c

多产程,电子病历

Showing 1 changed file with 381 additions and 262 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java View file @ 555860c
... ... @@ -934,243 +934,249 @@
934 934 List<SortIn> listDate = new ArrayList();
935 935  
936 936 if (CollectionUtils.isNotEmpty(list)) {
937   -// Patients patients2 = findOnePatient(null, null, null, hospital, -1, true, exListQueryRequest.getPid(),false);
938 937 Patients patients2 = findOnePatient(null, null, null, groupsFacade.findGroupHospital(userId, true), -1, true, exListQueryRequest.getPid(), false);
939 938 antexListResult.convertToResult(null, patients2, null);
940 939  
941 940 HighScoreResult highScoreResult = findLastRisk(list.get(0).getPid(), false);
942 941 antexListResult.setRiskFactor(highScoreResult.getHighRisk());
943 942 antexListResult.setRiskScore(highScoreResult.getScoreStr());
944   -
945   - MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
946   - matDeliverQuery.setPid(list.get(0).getPid());
947   - matDeliverQuery.setYn(YnEnums.YES.getId());
948   - //分娩记录
949   - List<MaternalDeliverModel> modelList = matDeliverService.query(matDeliverQuery);
950   - for (MaternalDeliverModel model : modelList) {
951   - listDate.add(new SortIn(model));
952   - map.put(model.getId(), model);
953   - }
954   - //终止妊娠记录
955   - StopPregQuery query = new StopPregQuery();
956   - query.setYn(YnEnums.YES.getId());
957   - query.setPid(list.get(0).getPid());
958   - List<StopPregModel> stopPregs = stopPregnancyService.queryStopPreg(query);
959   - for (StopPregModel stopPregModel : stopPregs) {
960   - listDate.add(new SortIn(stopPregModel));
961   - map.put(stopPregModel.getId(), stopPregModel);
962   - }
963   - //排序集合
964 943 sortList(listDate);
  944 + distPatientData(list, sortList);
  945 + }
  946 + antexListResult.setData(sortList);
  947 + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(antexListResult);
965 948  
966   - //需要过滤掉建档就分娩的情况
967   - Date dueDate = null;
968   - if (CollectionUtils.isNotEmpty(listDate)) {
969   - String pid = "";
970   - int count = 0;
971   - for (int i = 0; i < listDate.size(); i++) {
972   - dueDate = listDate.get(i).getDate();
973   - Date end = new Date(listDate.get(i).getDate().getTime() + 86398000);
974   - List listData = new ArrayList();
975   - Organization organization = null;
976   - PatientsQuery patientsQuery1 = new PatientsQuery();
977   - patientsQuery1.setLastMensesEnd(end);
978   - patientsQuery1.setBuildType(1);
979   - patientsQuery1.setYn(YnEnums.YES.getId());
980   - //在区域组的时候不用查询隐藏档案
981   - if (null != groupsFacade.findByCurrentUserId(autoMatchFacade.getHospitalId(userId))) {
982   - patientsQuery1.setExtEnable(false);
983   - }
  949 + // MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
  950 + // matDeliverQuery.setPid(list.get(0).getPid());
  951 + // matDeliverQuery.setYn(YnEnums.YES.getId());
  952 + // //分娩记录
  953 + // List<MaternalDeliverModel> modelList = matDeliverService.query(matDeliverQuery);
  954 + // for (MaternalDeliverModel model : modelList) {
  955 + // listDate.add(new SortIn(model));
  956 + // map.put(model.getId(), model);
  957 + // }
  958 + // //终止妊娠记录
  959 + // StopPregQuery query = new StopPregQuery();
  960 + // query.setYn(YnEnums.YES.getId());
  961 + // query.setPid(list.get(0).getPid());
  962 + // List<StopPregModel> stopPregs = stopPregnancyService.queryStopPreg(query);
  963 + // for (StopPregModel stopPregModel : stopPregs) {
  964 + // listDate.add(new SortIn(stopPregModel));
  965 + // map.put(stopPregModel.getId(), stopPregModel);
  966 + // }
  967 + // //排序集合
984 968  
985   - if (listDate.size() > i + 1) {
986   - patientsQuery1.setLastMensesStart(new Date(listDate.get(i + 1).getDate().getTime() + 86398000));
987   - }
988   - pid = list.get(0).getPid();
989   - patientsQuery1.setPid(pid);
990   - List<Patients> patientses = patientsService.queryPatient1(patientsQuery1, "created");
991   - if (CollectionUtils.isNotEmpty(patientses)) {
992   - count = count + patientses.size();
993   - //TODO 处理自动分娩的情况
994   - updateAutoMatdel(patientses, list, i, dueDate, sortList, listDate, map);
995   - listData = new ArrayList();
996   - }
  969 + // sort(listData);
  970 + // updateEditEnable(listData, sortList);
  971 + // sortList.add(listData);
997 972  
998   - if (CollectionUtils.isNotEmpty(patientses)) {
  973 + // Date dueDate = null;
  974 + //
  975 + // //有分娩记录或终止妊娠记录
  976 + // if (CollectionUtils.isNotEmpty(listDate)) {
  977 + // String pid = "";
  978 + // int count = 0;
  979 + // for (int i = 0; i < listDate.size(); i++) {
  980 + // dueDate = listDate.get(i).getDate();
  981 + // Date end = new Date(listDate.get(i).getDate().getTime() + 86398000);
  982 + // List listData = new ArrayList();
  983 + // Organization organization = null;
  984 + // PatientsQuery patientsQuery1 = new PatientsQuery();
  985 + // patientsQuery1.setLastMensesEnd(end);
  986 + // patientsQuery1.setBuildType(1);
  987 + // patientsQuery1.setYn(YnEnums.YES.getId());
  988 + // //在区域组的时候不用查询隐藏档案
  989 + // if (null != groupsFacade.findByCurrentUserId(autoMatchFacade.getHospitalId(userId))) {
  990 + // patientsQuery1.setExtEnable(false);
  991 + // }
  992 + //
  993 + // if (listDate.size() > i + 1) {
  994 + // patientsQuery1.setLastMensesStart(new Date(listDate.get(i + 1).getDate().getTime() + 86398000));
  995 + // }
  996 + // pid = list.get(0).getPid();
  997 + // patientsQuery1.setPid(pid);
  998 + // List<Patients> patientses = patientsService.queryPatient1(patientsQuery1, "created");
  999 + // if (CollectionUtils.isNotEmpty(patientses)) {
  1000 + // count = count + patientses.size();
  1001 + // //TODO 处理自动分娩或终止妊娠的情况
  1002 + // updateAutoMatdel(patientses, list, i, dueDate, sortList, listDate, map);
  1003 + // listData = new ArrayList();
  1004 + // }
  1005 + //
  1006 + // if (CollectionUtils.isNotEmpty(patientses)) {
  1007 + //
  1008 + // List<SortIn> tmp = new ArrayList();
  1009 + // for (Patients patients : patientses) {
  1010 + // tmp.add(new SortIn(patients));
  1011 + // }
  1012 + // sortList(tmp);
  1013 + // Date min = null;
  1014 + // if (!tmp.isEmpty()) {
  1015 + // min = tmp.get(tmp.size() - 1).getDate();
  1016 + // }
  1017 + // //分娩前的数据,初诊、复诊、建档
  1018 + // buildPatientList(dueDate, patientses, listData, min, false);
999 1019  
1000   - List<SortIn> tmp = new ArrayList();
1001   - for (Patients patients : patientses) {
1002   - tmp.add(new SortIn(patients));
1003   - }
1004   - sortList(tmp);
1005   - Date min = null;
1006   - if (!tmp.isEmpty()) {
1007   - min = tmp.get(tmp.size() - 1).getDate();
1008   - }
1009   - //分娩前的数据
1010   - buildPatientList(dueDate, patientses, listData, min, false);
1011 1020  
1012   - PostReviewQuery postReviewQuery = new PostReviewQuery();
1013   - postReviewQuery.setStart(dueDate);
1014   - if (i > 0) {
1015   - //下次建档记录前都是产后复查,如果没有下个产程的数据就直接显示
1016   - postReviewQuery.setEnd(listDate.get(i - 1).getDate());
1017   - }
1018   - postReviewQuery.setPid(pid);
1019   - Object obj = map.get(listDate.get(i).getId());
1020   - if (obj instanceof MaternalDeliverModel) {
1021   - MaternalDeliverModel model = (MaternalDeliverModel) obj;
1022   - if (null != model.getHospitalId()) {
1023   - organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId()));
1024   - }
1025   - listData.add(new AntData((MaternalDeliverModel) obj, patientses.get(0).getLastMenses(), null != organization ? organization.getName() : ""));
1026   - } else if (obj instanceof StopPregModel) {
1027   - StopPregModel model = (StopPregModel) obj;
1028   - if (null != model.getHospitalId()) {
1029   - organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId()));
1030   - }
1031   - listData.add(new AntData(stopPregs.get(0), patientses.get(0).getLastMenses(), null != organization ? organization.getName() : ""));
1032   - }
  1021 + // Object obj = map.get(listDate.get(i).getId());
  1022 + // if (obj instanceof MaternalDeliverModel) {
  1023 + // MaternalDeliverModel model = (MaternalDeliverModel) obj;
  1024 + // if (null != model.getHospitalId()) {
  1025 + // organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId()));
  1026 + // }
  1027 + // listData.add(new AntData((MaternalDeliverModel) obj, patientses.get(0).getLastMenses(), null != organization ? organization.getName() : ""));
  1028 + // } else if (obj instanceof StopPregModel) {
  1029 + // StopPregModel model = (StopPregModel) obj;
  1030 + // if (null != model.getHospitalId()) {
  1031 + // organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId()));
  1032 + // }
  1033 + // listData.add(new AntData(stopPregs.get(0), patientses.get(0).getLastMenses(), null != organization ? organization.getName() : ""));
  1034 + // }
1033 1035  
  1036 +// //出院小结查询条件
  1037 +// DischargeAbstractMotherQuery dischargeAbstractMotherQuery = new DischargeAbstractMotherQuery();
  1038 +// dischargeAbstractMotherQuery.setPid(pid);
  1039 +// dischargeAbstractMotherQuery.setYn(YnEnums.YES.getId());
  1040 +// if (list.size() - 1 > i) {
  1041 +// dischargeAbstractMotherQuery.setStart(dueDate);
  1042 +// if (CollectionUtils.isNotEmpty(listDate)) {
  1043 +// //下次建档记录前都是产后复查,如果没有下个产程的数据就直接显示
  1044 +// if (listDate.size() > 1 && i > 1) {
  1045 +// dischargeAbstractMotherQuery.setEnd(listDate.get(i - 1).getDate());
  1046 +// }
  1047 +// }
  1048 +// }
  1049 +// //出院小结信息
  1050 +// List<DischargeAbstractMotherModel> dischargeAbstractMotherModels = dischargeAbstractMotherService.query(dischargeAbstractMotherQuery);
  1051 +// if (CollectionUtils.isNotEmpty(dischargeAbstractMotherModels)) {
  1052 +// for (DischargeAbstractMotherModel model : dischargeAbstractMotherModels) {
  1053 +// listData.add(new AntData(model, null != organization ? organization.getName() : "", dueDate));
  1054 +// }
  1055 +// }
  1056 +//
  1057 +// PostReviewQuery postReviewQuery = new PostReviewQuery();
  1058 +// postReviewQuery.setStart(dueDate);
  1059 +// if (i > 0) {
  1060 +// //下次建档记录前都是产后复查,如果没有下个产程的数据就直接显示
  1061 +// postReviewQuery.setEnd(listDate.get(i - 1).getDate());
  1062 +// }
  1063 +// postReviewQuery.setPid(pid);
  1064 +// //产后复查记录
  1065 +// List<PostReviewModel> reviewModels = postReviewService.findWithList(postReviewQuery);
  1066 +// if (CollectionUtils.isNotEmpty(reviewModels)) {
  1067 +// for (PostReviewModel postReviewModel : reviewModels) {
  1068 +// if (postReviewModel.getYn() == YnEnums.YES.getId()) {
  1069 +// if (null != postReviewModel.getHospitalId()) {
  1070 +// organization = organizationService.getOrganization(Integer.valueOf(postReviewModel.getHospitalId()));
  1071 +// }
  1072 +// listData.add(new AntData(postReviewModel, null != organization ? organization.getName() : "", patientses.get(patientses.size() - 1).getFmDate()));
  1073 +// }
  1074 +// }
  1075 +// }
  1076 +// }
  1077 +// if (!listData.isEmpty()) {
  1078 +// sort(listData);
  1079 +// updateEditEnable(listData, sortList);
  1080 +// sortList.add(listData);
  1081 +// // Collections.reverse(sortList);
  1082 +// }
  1083 +// }
  1084 +// if (list.size() > count) {
  1085 +// //分娩记录剩下的建档
  1086 +// PatientsQuery patientsQuery1 = new PatientsQuery();
  1087 +// patientsQuery1.setYn(YnEnums.YES.getId());
  1088 +// patientsQuery1.setPid(pid);
  1089 +// patientsQuery1.setLastMensesStart(new Date(listDate.get(0).getDate().getTime()));
  1090 +// patientsQuery1.setType(1);
  1091 +// patientsQuery1.setBuildType(1);
  1092 +// List<Patients> patientsList = patientsService.queryPatient(patientsQuery1);
  1093 +// List list1 = new ArrayList();
  1094 +// List<SortIn> tmp = new ArrayList();
  1095 +// for (Patients patients : patientsList) {
  1096 +// tmp.add(new SortIn(patients));
  1097 +// }
  1098 +// sortList(tmp);
  1099 +// Date min = null;
  1100 +// if (!tmp.isEmpty()) {
  1101 +// min = tmp.get(tmp.size() - 1).getDate();
  1102 +// }
  1103 +// List l = buildPatientList(new Date(), patientsList, list1, min, false);
  1104 +// if (!l.isEmpty()) {
  1105 +// sort(l);
  1106 +//
  1107 +// List list2 = new ArrayList();
  1108 +// list2.add(l);
  1109 +// list2.addAll(sortList);
  1110 +// sortList = list2;
  1111 +// updateEditEnable(l, sortList);
  1112 +// l = new ArrayList();
  1113 +// }
  1114 +// }
  1115 +//
  1116 +// } else { //没有终止的情况
  1117 +// List list1 = new ArrayList();
  1118 +// List<SortIn> tmp = new ArrayList();
  1119 +// for (Patients patients : list) {
  1120 +// tmp.add(new SortIn(patients));
  1121 +// }
  1122 +// int size = list.size();
  1123 +// sortList(tmp);
  1124 +// Date min = null;
  1125 +// if (!tmp.isEmpty()) {
  1126 +// min = tmp.get(tmp.size() - 1).getDate();
  1127 +// }
  1128 +// updateAutoMatdel(list, list, 0, dueDate, sortList, null, null);
  1129 +// if (size != list.size()) {
  1130 +// list1 = new ArrayList();
  1131 +// }
  1132 +// /*if(null==dueDate){
  1133 +// dueDate= new Date();
  1134 +// }*/
  1135 +// //TODO buildPatientList(dueDate, list, list1, min, false);
  1136 +// List l = buildPatientList(dueDate, list, list1, min, false);
  1137 +// if (!l.isEmpty()) {
  1138 +// sort(l);
  1139 +// updateEditEnable(l, sortList);
  1140 +// sortList.add(l);
  1141 +// }
  1142 +// }
1034 1143  
1035   - DischargeAbstractMotherQuery dischargeAbstractMotherQuery = new DischargeAbstractMotherQuery();
1036   - dischargeAbstractMotherQuery.setPid(pid);
1037   - dischargeAbstractMotherQuery.setYn(YnEnums.YES.getId());
1038   - if (list.size() - 1 > i) {
1039   - dischargeAbstractMotherQuery.setStart(dueDate);
1040   - if (CollectionUtils.isNotEmpty(listDate)) {
1041   - //下次建档记录前都是产后复查,如果没有下个产程的数据就直接显示
1042   - if (listDate.size() > 1 && i > 1) {
1043   - dischargeAbstractMotherQuery.setEnd(listDate.get(i - 1).getDate());
1044   - }
1045   - }
1046   - }
1047   -
1048   - List<DischargeAbstractMotherModel> dischargeAbstractMotherModels = dischargeAbstractMotherService.query(dischargeAbstractMotherQuery);
1049   -
1050   - if (CollectionUtils.isNotEmpty(dischargeAbstractMotherModels)) {
1051   - for (DischargeAbstractMotherModel model : dischargeAbstractMotherModels) {
1052   - listData.add(new AntData(model, null != organization ? organization.getName() : "", dueDate));
1053   - }
1054   - }
1055   -
1056   -
1057   - //产后复查记录
1058   - List<PostReviewModel> reviewModels = postReviewService.findWithList(postReviewQuery);
1059   - if (CollectionUtils.isNotEmpty(reviewModels)) {
1060   - for (PostReviewModel postReviewModel : reviewModels) {
1061   - if (postReviewModel.getYn() == YnEnums.YES.getId()) {
1062   - if (null != postReviewModel.getHospitalId()) {
1063   - organization = organizationService.getOrganization(Integer.valueOf(postReviewModel.getHospitalId()));
1064   - }
1065   - listData.add(new AntData(postReviewModel, null != organization ? organization.getName() : "", patientses.get(patientses.size() - 1).getFmDate()));
1066   - }
1067   - }
1068   - }
1069   - }
1070   - if (!listData.isEmpty()) {
1071   - sort(listData);
1072   - updateEditEnable(listData, sortList);
1073   - sortList.add(listData);
1074   -// Collections.reverse(sortList);
1075   - }
1076   - }
1077   - if (list.size() > count) {
1078   - //分娩记录剩下的建档
1079   - PatientsQuery patientsQuery1 = new PatientsQuery();
1080   - patientsQuery1.setYn(YnEnums.YES.getId());
1081   - patientsQuery1.setPid(pid);
1082   - patientsQuery1.setLastMensesStart(new Date(listDate.get(0).getDate().getTime()));
1083   - patientsQuery1.setType(1);
1084   - patientsQuery1.setBuildType(1);
1085   - List<Patients> patientsList = patientsService.queryPatient(patientsQuery1);
1086   - List list1 = new ArrayList();
1087   - List<SortIn> tmp = new ArrayList();
1088   - for (Patients patients : patientsList) {
1089   - tmp.add(new SortIn(patients));
1090   - }
1091   - sortList(tmp);
1092   - Date min = null;
1093   - if (!tmp.isEmpty()) {
1094   - min = tmp.get(tmp.size() - 1).getDate();
1095   - }
1096   - List l = buildPatientList(new Date(), patientsList, list1, min, false);
1097   - if (!l.isEmpty()) {
1098   - sort(l);
1099   -
1100   - List list2 = new ArrayList();
1101   - list2.add(l);
1102   - list2.addAll(sortList);
1103   - sortList = list2;
1104   - updateEditEnable(l, sortList);
1105   - l = new ArrayList();
1106   - }
1107   - }
1108   -
1109   - } else {
1110   - //没有终止的情况
1111   - List list1 = new ArrayList();
1112   - List<SortIn> tmp = new ArrayList();
1113   - for (Patients patients : list) {
1114   - tmp.add(new SortIn(patients));
1115   - }
1116   - int size = list.size();
1117   - sortList(tmp);
1118   - Date min = null;
1119   - if (!tmp.isEmpty()) {
1120   - min = tmp.get(tmp.size() - 1).getDate();
1121   - }
1122   - updateAutoMatdel(list, list, 0, dueDate, sortList, null, null);
1123   - if (size != list.size()) {
1124   - list1 = new ArrayList();
1125   - }
1126   - /*if(null==dueDate){
1127   - dueDate= new Date();
1128   - }*/
1129   - //TODO buildPatientList(dueDate, list, list1, min, false);
1130   - List l = buildPatientList(dueDate, list, list1, min, false);
1131   - if (!l.isEmpty()) {
1132   - sort(l);
1133   - updateEditEnable(l, sortList);
1134   - sortList.add(l);
1135   - }
1136   - }
1137   - }
1138   - antexListResult.setData(sortList);
1139   - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(antexListResult);
1140 1144 }
1141 1145  
1142 1146 /**
1143   - * 处理自动分娩的情况
  1147 + * 处理自动分娩或终止妊娠的情况
1144 1148 */
1145 1149 private void updateAutoMatdel(List<Patients> patientses, List<Patients> list, int i, Date dueDate, List sortList, List<SortIn> listDate, Map map) {
1146 1150 Iterator<Patients> iterator = patientses.iterator();
1147 1151 Organization organization = null;
1148 1152 String pid = "";
  1153 + String patientId = "";
1149 1154 List listData = new ArrayList();
1150 1155 Date lastMenses = null;//上一次的末次月经
  1156 + //遍历产程,只处理分娩或者终止妊娠的数据
1151 1157 while (iterator.hasNext()) {
1152 1158 Patients patients = iterator.next();
1153 1159  
1154   - //处理建档就分娩的情况
  1160 + //处理建档就分娩的情况,根据末次月经计算预产期
1155 1161 Date date = DateUtil.addWeek(patients.getLastMenses(), 42);
1156   -
  1162 + //获取当前时间的年月日
1157 1163 Date currentDate = DateUtil.formatDate(new Date());
1158   -
1159   -
  1164 + //如果当前时间小于预产期或者已经自动分娩,或者终止妊娠
1160 1165 if ((date.getTime() <= currentDate.getTime() || patients.getBuildType() == 2 || (patients.getIsAutoFm() != null && patients.getIsAutoFm() == 1)) || patients.getType() == 3 && patients.getFmDate() != null) {
1161 1166 //建档记录
1162 1167 if (null != patients.getHospitalId()) {
1163 1168 organization = organizationService.getOrganization(Integer.valueOf(patients.getHospitalId()));
1164 1169 }
  1170 + //获取personId
1165 1171 pid = patients.getPid();
  1172 + //获取产程ID
  1173 + patientId = patients.getId();
1166 1174 //当主档案的医院不在group组里需要显示本来的隐藏档案
1167 1175 if (!"2".equals(patients.getEnable())) {
1168 1176 listData.add(new AntData(patients, null != organization ? organization.getName() : ""));
1169 1177 }
1170 1178  
1171   -// if (null == dueDate && null != patients.getFmDate()) {
1172 1179 dueDate = patients.getFmDate();
1173   -// }
1174 1180  
1175 1181 //初诊记录
1176 1182 AntExChuQuery antExChuQuery = new AntExChuQuery();
1177 1183  
1178 1184  
... ... @@ -1182,23 +1188,23 @@
1182 1188 antExChuQuery.setEnd(new Date(patients.getFmDate().getTime() + 86398000));
1183 1189 }
1184 1190  
1185   - antExChuQuery.setPid(pid);
1186   -
  1191 + // antExChuQuery.setPid(pid);
  1192 + antExChuQuery.setParentId(patientId);
1187 1193 List<AntExChuModel> antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery);
1188 1194 if (CollectionUtils.isNotEmpty(antExChuModels)) {
1189 1195 for (AntExChuModel an : antExChuModels) {
1190 1196 if (null != an.getHospitalId()) {
1191 1197 organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId()));
1192 1198 }
1193   -
1194   - listData.add(new AntData(an, null != organization ? organization.getName() : "", patientses.get(0).getLastMenses()));
  1199 + listData.add(new AntData(an, null != organization ? organization.getName() : "", patients.getLastMenses()));
1195 1200 }
1196 1201 }
1197 1202  
1198 1203 //复诊记录
1199 1204 AntExQuery antExQuery = new AntExQuery();
1200 1205 antExQuery.setYn(YnEnums.YES.getId());
1201   - antExQuery.setPid(pid);
  1206 + // antExQuery.setPid(pid);
  1207 + antExQuery.setParentId(patientId);
1202 1208 antExQuery.setStart(patients.getBookbuildingDate());
1203 1209 if (null == patients.getFmDate()) {
1204 1210 antExQuery.setEnd(new Date(DateUtil.addWeek(patients.getLastMenses(), 42).getTime() + 86398000));
... ... @@ -1213,7 +1219,7 @@
1213 1219 organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId()));
1214 1220 }
1215 1221  
1216   - listData.add(new AntData(an, null != organization ? organization.getName() : "", patientses.get(0).getLastMenses()));
  1222 + listData.add(new AntData(an, null != organization ? organization.getName() : "", patients.getLastMenses()));
1217 1223 }
1218 1224 }
1219 1225 /*
... ... @@ -1231,7 +1237,8 @@
1231 1237 if (null != map) {
1232 1238 MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
1233 1239 matDeliverQuery.setYn(YnEnums.YES.getId());
1234   - matDeliverQuery.setPid(pid);
  1240 + // matDeliverQuery.setPid(pid);
  1241 + matDeliverQuery.setParentId(patientId);
1235 1242 // matDeliverQuery.setNeStart(true);
1236 1243 // matDeliverQuery.setNeEnd(true);
1237 1244 matDeliverQuery.setCreatedStart(dueDate);
1238 1245  
... ... @@ -1250,12 +1257,13 @@
1250 1257 organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId()));
1251 1258 }
1252 1259  
1253   - listData.add(new AntData(model, patientses.get(0).getLastMenses(), null != organization ? organization.getName() : ""));
  1260 + listData.add(new AntData(model, patients.getLastMenses(), null != organization ? organization.getName() : ""));
1254 1261 }
1255 1262 }
1256 1263  
1257 1264 DischargeAbstractMotherQuery dischargeAbstractMotherQuery = new DischargeAbstractMotherQuery();
1258   - dischargeAbstractMotherQuery.setPid(pid);
  1265 + // dischargeAbstractMotherQuery.setPid(pid);
  1266 + dischargeAbstractMotherQuery.setPatientId(patientId);
1259 1267 dischargeAbstractMotherQuery.setYn(YnEnums.YES.getId());
1260 1268 if (list.size() - 1 > i) {
1261 1269 dischargeAbstractMotherQuery.setStart(dueDate);
... ... @@ -1279,7 +1287,8 @@
1279 1287 if (null != patients.getDueStatus() && 1 == patients.getDueStatus()) {
1280 1288 StopPregQuery stopPregQuery = new StopPregQuery();
1281 1289 stopPregQuery.setYn(YnEnums.YES.getId());
1282   - stopPregQuery.setPid(pid);
  1290 + // stopPregQuery.setPid(pid);
  1291 + stopPregQuery.setPatientId(patientId);
1283 1292 if (list.size() - 1 > i) {
1284 1293 stopPregQuery.setStopDateStart(dueDate);
1285 1294 if (CollectionUtils.isNotEmpty(listDate)) {
... ... @@ -1317,7 +1326,8 @@
1317 1326 }
1318 1327 }
1319 1328 postReviewQuery.setYn(YnEnums.YES.getId());
1320   - postReviewQuery.setPid(pid);
  1329 + // postReviewQuery.setPid(pid);
  1330 + postReviewQuery.setParentId(patientId);
1321 1331  
1322 1332  
1323 1333 //产后复查记录
... ... @@ -1350,6 +1360,136 @@
1350 1360  
1351 1361  
1352 1362 /**
  1363 + * 处理产程数据
  1364 + */
  1365 + private void distPatientData(List<Patients> patientses, List sortList) {
  1366 + Iterator<Patients> iterator = patientses.iterator();
  1367 + Organization organization = null;
  1368 + String patientId = "";
  1369 + while (iterator.hasNext()) {
  1370 + List listData = new ArrayList();
  1371 + Patients patients = iterator.next();
  1372 + //建档记录
  1373 + if (null != patients.getHospitalId()) {
  1374 + organization = organizationService.getOrganization(Integer.valueOf(patients.getHospitalId()));
  1375 + }
  1376 + //获取产程ID
  1377 + patientId = patients.getId();
  1378 + //当主档案的医院不在group组里需要显示本来的隐藏档案
  1379 + if (!"2".equals(patients.getEnable())) {
  1380 + listData.add(new AntData(patients, null != organization ? organization.getName() : ""));
  1381 + }
  1382 +
  1383 + //初诊记录
  1384 + AntExChuQuery antExChuQuery = new AntExChuQuery();
  1385 + antExChuQuery.setYn(YnEnums.YES.getId());
  1386 + antExChuQuery.setStart(patients.getBookbuildingDate());
  1387 + if (null == patients.getFmDate()) {
  1388 + antExChuQuery.setEnd(new Date(DateUtil.addWeek(patients.getLastMenses(), 42).getTime() + 86398000));
  1389 + } else {
  1390 + antExChuQuery.setEnd(new Date(patients.getFmDate().getTime() + 86398000));
  1391 + }
  1392 + antExChuQuery.setParentId(patientId);
  1393 + List<AntExChuModel> antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery);
  1394 + if (CollectionUtils.isNotEmpty(antExChuModels)) {
  1395 + for (AntExChuModel an : antExChuModels) {
  1396 + if (null != an.getHospitalId()) {
  1397 + organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId()));
  1398 + }
  1399 + listData.add(new AntData(an, null != organization ? organization.getName() : "", patients.getLastMenses()));
  1400 + }
  1401 + }
  1402 +
  1403 + //复诊记录
  1404 + AntExQuery antExQuery = new AntExQuery();
  1405 + antExQuery.setYn(YnEnums.YES.getId());
  1406 + antExQuery.setParentId(patientId);
  1407 + antExQuery.setStart(patients.getBookbuildingDate());
  1408 + if (null == patients.getFmDate()) {
  1409 + antExQuery.setEnd(new Date(DateUtil.addWeek(patients.getLastMenses(), 42).getTime() + 86398000));
  1410 + } else {
  1411 + antExQuery.setEnd(new Date(patients.getFmDate().getTime() + 86398000));
  1412 + }
  1413 +
  1414 + List<AntenatalExaminationModel> list1 = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery());
  1415 + if (CollectionUtils.isNotEmpty(list1)) {
  1416 + for (AntenatalExaminationModel an : list1) {
  1417 + if (null != an.getHospitalId()) {
  1418 + organization = organizationService.getOrganization(Integer.valueOf(an.getHospitalId()));
  1419 + }
  1420 +
  1421 + listData.add(new AntData(an, null != organization ? organization.getName() : "", patients.getLastMenses()));
  1422 + }
  1423 + }
  1424 + //分娩记录
  1425 + MatDeliverQuery matDeliverQuery = new MatDeliverQuery();
  1426 + matDeliverQuery.setYn(YnEnums.YES.getId());
  1427 + matDeliverQuery.setParentId(patientId);
  1428 + List<MaternalDeliverModel> l = matDeliverService.query(matDeliverQuery);
  1429 + if (CollectionUtils.isNotEmpty(l)) {
  1430 + MaternalDeliverModel model = l.get(0);
  1431 + if (null != model.getHospitalId()) {
  1432 + organization = organizationService.getOrganization(Integer.valueOf(model.getHospitalId()));
  1433 + }
  1434 +
  1435 + listData.add(new AntData(model, patients.getLastMenses(), null != organization ? organization.getName() : ""));
  1436 + }
  1437 + //出院小结
  1438 + DischargeAbstractMotherQuery dischargeAbstractMotherQuery = new DischargeAbstractMotherQuery();
  1439 + dischargeAbstractMotherQuery.setPatientId(patientId);
  1440 + dischargeAbstractMotherQuery.setYn(YnEnums.YES.getId());
  1441 + List<DischargeAbstractMotherModel> dischargeAbstractMotherModels = dischargeAbstractMotherService.query(dischargeAbstractMotherQuery);
  1442 +
  1443 + if (CollectionUtils.isNotEmpty(dischargeAbstractMotherModels)) {
  1444 + for (DischargeAbstractMotherModel model : dischargeAbstractMotherModels) {
  1445 + listData.add(new AntData(model, null != organization ? organization.getName() : "", patients.getFmDate()));
  1446 + }
  1447 + }
  1448 +
  1449 + //终止妊娠的情况
  1450 + if (null != patients.getDueStatus() && 1 == patients.getDueStatus()) {
  1451 + StopPregQuery stopPregQuery = new StopPregQuery();
  1452 + stopPregQuery.setYn(YnEnums.YES.getId());
  1453 + stopPregQuery.setPatientId(patientId);
  1454 + List<StopPregModel> models = stopPregnancyService.queryStopPreg(stopPregQuery);
  1455 + if (CollectionUtils.isNotEmpty(models)) {
  1456 + for (StopPregModel stop : models) {
  1457 + if (null != stop.getHospitalId()) {
  1458 + organization = organizationService.getOrganization(Integer.valueOf(stop.getHospitalId()));
  1459 + }
  1460 + listData.add(new AntData(stop, patients.getLastMenses(), null != organization ? organization.getName() : ""));
  1461 + }
  1462 + }
  1463 + } else {
  1464 + PostReviewQuery postReviewQuery = new PostReviewQuery();
  1465 + postReviewQuery.setYn(YnEnums.YES.getId());
  1466 + postReviewQuery.setParentId(patientId);
  1467 +
  1468 + //产后复查记录
  1469 + List<PostReviewModel> reviewModels = postReviewService.findWithList(postReviewQuery);
  1470 + if (CollectionUtils.isNotEmpty(reviewModels)) {
  1471 + if (CollectionUtils.isNotEmpty(listData)) {
  1472 + for (PostReviewModel postReviewModel : reviewModels) {
  1473 + if (postReviewModel.getYn() == YnEnums.YES.getId()) {
  1474 + if (null != postReviewModel.getHospitalId()) {
  1475 + organization = organizationService.getOrganization(Integer.valueOf(postReviewModel.getHospitalId()));
  1476 + }
  1477 +
  1478 + listData.add(new AntData(postReviewModel, null != organization ? organization.getName() : "", patients.getFmDate()));
  1479 + }
  1480 + }
  1481 + }
  1482 + }
  1483 + }
  1484 + if (CollectionUtils.isNotEmpty(listData)) {
  1485 + sort(listData);
  1486 + updateEditEnable(listData, sortList);
  1487 + sortList.add(listData);
  1488 + }
  1489 + }
  1490 + }
  1491 +
  1492 + /**
1353 1493 * 修改按钮控制
1354 1494 *
1355 1495 * @param list 同一产程记录
... ... @@ -1363,7 +1503,7 @@
1363 1503 antData.setEnableEdit("0");
1364 1504 }
1365 1505 }
1366   - //如果最后一条是复查 4 5 6 分娩 复查 终止妊娠
  1506 + //如果最后一条是复查 4 5 6 分娩 产后复查 终止妊娠
1367 1507 if ("4567".indexOf(list.get(list.size() - 1).getType()) > -1) {
1368 1508 for (int i = 0; i < list.size() - 1; i++) {
1369 1509 list.get(i).setEnableEdit("0");
1370 1510  
... ... @@ -1976,13 +2116,14 @@
1976 2116 matDeliverQuery.setPid(patients.getPid());
1977 2117 matDeliverQuery.setYn(YnEnums.YES.getId());
1978 2118  
  2119 + //查询分娩记录
1979 2120 List<MaternalDeliverModel> list1 = matDeliverService.query(matDeliverQuery);
1980 2121  
1981 2122 StopPregQuery stopPregQuery = new StopPregQuery();
1982 2123  
1983 2124 stopPregQuery.setPid(patients.getPid());
1984 2125 stopPregQuery.setYn(YnEnums.YES.getId());
1985   -
  2126 + //查询终止妊娠
1986 2127 List<StopPregModel> list2 = stopPregnancyService.queryStopPreg(stopPregQuery);
1987 2128  
1988 2129  
... ... @@ -2010,6 +2151,8 @@
2010 2151 max = new Date(sortList.get(0).getDate().getTime() + 400000);
2011 2152 }
2012 2153 antExChuQuery.setStart(max);
  2154 +
  2155 + // System.out.println("初诊查询:"+antExChuQuery.convertToQuery().convertToMongoQuery());
2013 2156 //获取初诊记录
2014 2157 List<AntExChuModel> antExChulist = antenatalExaminationService.queryAntExChu(antExChuQuery);
2015 2158  
... ... @@ -2034,6 +2177,7 @@
2034 2177 antExQuery1.setPid(patients.getPid());
2035 2178 antExQuery1.setYn(YnEnums.YES.getId());
2036 2179 antExQuery1.setStart(max);
  2180 + // System.out.println("复诊查询:"+antExQuery1.convertToQuery().convertToMongoQuery());
2037 2181 List<AntenatalExaminationModel> examinationModelList = antenatalExaminationService.queryAntenatalExamination(antExQuery1.convertToQuery().addOrder(Sort.Direction.DESC, "created"));
2038 2182  
2039 2183 String lastTime = "";
2040 2184  
2041 2185  
2042 2186  
2043 2187  
2044 2188  
2045 2189  
2046 2190  
... ... @@ -2568,70 +2712,45 @@
2568 2712 List<String> values = new ArrayList<>();
2569 2713  
2570 2714  
2571   - Patients patients = patientsService.findOnePatientById(patientId);
2572   -
2573   - List<String> patientIds = new ArrayList<>();
2574   -
2575   - if (patients != null)
2576   - {
2577   - PatientsQuery patientsQuery = new PatientsQuery();
2578   - patientsQuery.setYn(YnEnums.YES.getId());
2579   - patientsQuery.setPid(patients.getPid());
2580   - List<Patients> patientses = patientsService.queryPatient(patientsQuery);
2581   - if (CollectionUtils.isNotEmpty(patientses))
2582   - {
2583   - for (Patients pat : patientses)
2584   - {
2585   - patientIds.add(pat.getId());
2586   - }
2587   - }
2588   - }
2589   - else
2590   - {
2591   - patientIds.add(patientId);
2592   - }
2593   -
2594 2715 List<Map<String,String>> tables = new LinkedList<>();
2595 2716  
2596 2717 AntExChuQuery antExChuQuery = new AntExChuQuery();
2597 2718 antExChuQuery.setYn(YnEnums.YES.getId());
2598   - antExChuQuery.setParentIds(patientIds);
2599   - List<AntExChuModel> antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery,Sort.Direction.ASC, "created");
  2719 + antExChuQuery.setParentId(patientId);
  2720 + List<AntExChuModel> antExChuModels = antenatalExaminationService.queryAntExChu(antExChuQuery);
2600 2721 if (CollectionUtils.isNotEmpty(antExChuModels))
2601 2722 {
2602   - for (AntExChuModel chumodel : antExChuModels)
  2723 + AntExChuModel chumodel = antExChuModels.get(0);
  2724 + if (StringUtils.isNotEmpty(chumodel.getGonggao()) || StringUtils.isNotEmpty(chumodel.getGonggaoSelect()))
2603 2725 {
2604   - if (StringUtils.isNotEmpty(chumodel.getGonggao()) || StringUtils.isNotEmpty(chumodel.getGonggaoSelect()))
  2726 + Map<String,String> item = new HashMap<>();
  2727 + String value = "";
  2728 + if (StringUtils.isNotEmpty(chumodel.getGonggaoSelect()) )
2605 2729 {
2606   - Map<String,String> item = new HashMap<>();
2607   - String value = "";
2608   - if (StringUtils.isNotEmpty(chumodel.getGonggaoSelect()) )
2609   - {
2610   - if (StringUtils.isNotEmpty(chumodel.getGonggaoType())) {
2611   - value = GongJingEnums.getGongGaoNameById(chumodel.getGonggaoSelect()) + "," + GongJingEnums.getHengZhiNameById(chumodel.getGonggaoType());
2612   - } else {
2613   - value = GongJingEnums.getGongGaoNameById(chumodel.getGonggaoSelect());
2614   - }
  2730 + if (StringUtils.isNotEmpty(chumodel.getGonggaoType())) {
  2731 + value = GongJingEnums.getGongGaoNameById(chumodel.getGonggaoSelect()) + "," + GongJingEnums.getHengZhiNameById(chumodel.getGonggaoType());
  2732 + } else {
  2733 + value = GongJingEnums.getGongGaoNameById(chumodel.getGonggaoSelect());
2615 2734 }
2616   - else if (StringUtils.isNotEmpty(chumodel.getGonggao()))
2617   - {
2618   - value = chumodel.getGonggao();
2619   - }
2620   - item.put("value", value);
2621   - item.put("time", DateUtil.getyyyy_MM_dd(chumodel.getCheckTime()));
2622   - if (StringUtils.isNotEmpty(chumodel.getGonggao()) && (StringUtils.isNumeric(chumodel.getGonggao()) || Pattern.compile("^[-\\+]?[.\\d]*$").matcher(chumodel.getGonggao()).matches()))
2623   - {
2624   - titles.add(DateUtil.getyyyy_MM_dd(chumodel.getCheckTime()));
2625   - values.add(chumodel.getGonggao());
2626   - }
2627   - tables.add(item);
2628 2735 }
  2736 + else if (StringUtils.isNotEmpty(chumodel.getGonggao()))
  2737 + {
  2738 + value = chumodel.getGonggao();
  2739 + }
  2740 + item.put("value", value);
  2741 + item.put("time", DateUtil.getyyyy_MM_dd(chumodel.getCheckTime()));
  2742 + if (StringUtils.isNotEmpty(chumodel.getGonggao()) && (StringUtils.isNumeric(chumodel.getGonggao()) || Pattern.compile("^[-\\+]?[.\\d]*$").matcher(chumodel.getGonggao()).matches()))
  2743 + {
  2744 + titles.add(DateUtil.getyyyy_MM_dd(chumodel.getCheckTime()));
  2745 + values.add(chumodel.getGonggao());
  2746 + }
  2747 + tables.add(item);
2629 2748 }
2630 2749 }
2631 2750  
2632 2751  
2633 2752 AntExQuery antExQuery = new AntExQuery();
2634   - antExQuery.setParentIds(patientIds);
  2753 + antExQuery.setParentId(patientId);
2635 2754 antExQuery.setYn(YnEnums.YES.getId());
2636 2755 List<AntenatalExaminationModel> examinationModelList = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.ASC, "created"));
2637 2756 if (CollectionUtils.isNotEmpty(examinationModelList))