Commit 3829ae6acb900c45dff1c177286491d85ee7ffba

Authored by liquanyu
1 parent bbb18c9ea4

孕妇学校

Showing 5 changed files with 298 additions and 14 deletions

platform-common/src/main/java/com/lyms/platform/common/constants/ErrorCodeConstants.java View file @ 3829ae6
... ... @@ -62,5 +62,8 @@
62 62 public static final int NO_POWER = 4021;
63 63 //区域模式运行
64 64 public static final String RUN_MODE="1";
  65 +
  66 + //数据已过期
  67 + public static final int DATA_EXPIRE = 4108;
65 68 }
platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java View file @ 3829ae6
... ... @@ -130,6 +130,9 @@
130 130 //查询号
131 131 private String queryNo;
132 132  
  133 + //查询手机就诊卡证件号
  134 + private String pvc;
  135 +
133 136 private String phoneOrCert;
134 137 private String[] pc;
135 138 private String[] pv;
... ... @@ -137,6 +140,14 @@
137 140 private Integer buildDaysStart;
138 141 private Integer buildDaysEnd;
139 142  
  143 + public String getPvc() {
  144 + return pvc;
  145 + }
  146 +
  147 + public void setPvc(String pvc) {
  148 + this.pvc = pvc;
  149 + }
  150 +
140 151 public String getNotoRiskFactor() {
141 152 return notoRiskFactor;
142 153 }
... ... @@ -1200,6 +1211,19 @@
1200 1211 c1 = c.orCondition(new MongoCondition[]{con1, con2, con3, con4, con5}).getCriteria();
1201 1212 }
1202 1213 }
  1214 +
  1215 + if (null != pvc) {
  1216 + MongoCondition c = MongoCondition.newInstance();
  1217 + MongoCondition con1 = MongoCondition.newInstance("phone", pvc, MongoOper.IS);
  1218 + MongoCondition con3 = MongoCondition.newInstance("cardNo", pvc, MongoOper.IS);
  1219 + MongoCondition con5 = MongoCondition.newInstance("vcCardNo", pvc, MongoOper.IS);
  1220 + if (c1 != null) {
  1221 + c1 = c1.andOperator(c.orCondition(new MongoCondition[]{con1, con3, con5}).getCriteria());
  1222 + } else {
  1223 + c1 = c.orCondition(new MongoCondition[]{con1, con3, con5}).getCriteria();
  1224 + }
  1225 + }
  1226 +
1203 1227 if (null != phoneOrCert) {
1204 1228 MongoCondition c = MongoCondition.newInstance();
1205 1229 MongoCondition con1 = MongoCondition.newInstance("phone", phoneOrCert, MongoOper.IS);
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientCourseController.java View file @ 3829ae6
... ... @@ -13,7 +13,7 @@
13 13  
14 14  
15 15 /**
16   - * 孕妇预约和签到
  16 + * 孕妇预约和签到课程
17 17 */
18 18 @Controller
19 19 public class PatientCourseController extends BaseController {
... ... @@ -72,6 +72,60 @@
72 72 HttpServletRequest request) {
73 73  
74 74 return patientCourseFacade.queryOrderPatient(queryNo, getUserId(request));
  75 + }
  76 +
  77 +
  78 + /**
  79 + * 搜索签到详情
  80 + * @param queryNo
  81 + * @param request
  82 + * @return
  83 + */
  84 + @RequestMapping(method = RequestMethod.GET, value = "/querySignPatient")
  85 + @ResponseBody
  86 + @TokenRequired
  87 + public BaseResponse querySignPatient(
  88 + @RequestParam(required = true) String queryNo,
  89 + HttpServletRequest request) {
  90 +
  91 + return patientCourseFacade.querySignPatient(queryNo, getUserId(request));
  92 + }
  93 +
  94 +
  95 + /**
  96 + * 孕妇预约课程
  97 + * @param courseId
  98 + * @param patientId
  99 + * @param hospitalId
  100 + * @param orderType //预约类型 1 院内 2 小程序
  101 + * @param request
  102 + * @return
  103 + */
  104 + @RequestMapping(method = RequestMethod.GET, value = "/orderCourse")
  105 + @ResponseBody
  106 + @TokenRequired
  107 + public BaseResponse orderCourse(
  108 + @RequestParam(required = true) String courseId,
  109 + @RequestParam(required = true) String patientId,
  110 + @RequestParam(required = true) String hospitalId,
  111 + @RequestParam(required = true) Integer orderType,
  112 + HttpServletRequest request) {
  113 +
  114 + return patientCourseFacade.orderCourse(courseId, patientId, hospitalId, orderType, getUserId(request));
  115 + }
  116 +
  117 +
  118 + @RequestMapping(method = RequestMethod.GET, value = "/signCourse")
  119 + @ResponseBody
  120 + @TokenRequired
  121 + public BaseResponse signCourse(
  122 + @RequestParam(required = true) String courseId,
  123 + @RequestParam(required = true) String patientId,
  124 + @RequestParam(required = true) String hospitalId,
  125 + @RequestParam(required = true) Integer orderType,
  126 + HttpServletRequest request) {
  127 +
  128 + return patientCourseFacade.signCourse(courseId,patientId,hospitalId, orderType,getUserId(request));
75 129 }
76 130 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java View file @ 3829ae6
1 1 package com.lyms.platform.operate.web.facade;
2 2  
3 3  
  4 +import com.lyms.platform.biz.service.CourseService;
4 5 import com.lyms.platform.biz.service.CourseTypeService;
5 6 import com.lyms.platform.biz.service.PatientCourseService;
6 7 import com.lyms.platform.biz.service.PatientsService;
7 8 import com.lyms.platform.common.constants.ErrorCodeConstants;
8 9 import com.lyms.platform.common.enums.YnEnums;
9 10 import com.lyms.platform.common.result.BaseListResponse;
  11 +import com.lyms.platform.common.result.BaseObjectResponse;
10 12 import com.lyms.platform.common.result.BaseResponse;
11 13 import com.lyms.platform.common.utils.DateUtil;
12 14 import com.lyms.platform.operate.web.result.PatientCourseResult;
... ... @@ -16,6 +18,7 @@
16 18 import com.lyms.platform.pojo.Patients;
17 19 import com.lyms.platform.query.CourseQuery;
18 20 import com.lyms.platform.query.PatientCourseQuery;
  21 +import com.lyms.platform.query.PatientsQuery;
19 22 import org.apache.commons.collections.CollectionUtils;
20 23 import org.apache.commons.lang.StringUtils;
21 24 import org.springframework.beans.factory.annotation.Autowired;
22 25  
... ... @@ -48,7 +51,10 @@
48 51 @Autowired
49 52 private PatientsService patientsService;
50 53  
  54 + @Autowired
  55 + private CourseService courseService;
51 56  
  57 +
52 58 public BaseResponse getPatientCourseList(Integer status,String courseId, Integer page,
53 59 Integer limit, Integer userId) {
54 60  
55 61  
56 62  
57 63  
58 64  
59 65  
... ... @@ -64,16 +70,38 @@
64 70 //状态 1预约,2签到
65 71 patientCourseQuery.setStatus(status);
66 72  
67   - List<PatientCourseResult> results = new ArrayList<>();
  73 + List<PatientCourseResult> results = getPatientCourse(patientCourseQuery);
68 74  
  75 + BaseListResponse objectResponse = new BaseListResponse();
  76 + objectResponse.setData(results);
  77 + objectResponse.setPageInfo(patientCourseQuery.getPageInfo());
  78 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  79 + objectResponse.setErrormsg("成功");
  80 + return objectResponse;
  81 + }
69 82  
70   - List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery);
71   - if (CollectionUtils.isNotEmpty(patientCourseModels))
  83 + public BaseResponse queryOrderPatient(String queryNo, Integer userId) {
  84 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  85 +
  86 + PatientCourseQuery patientCourseQuery = new PatientCourseQuery();
  87 + patientCourseQuery.setYn(YnEnums.YES.getId());
  88 +
  89 + patientCourseQuery.setHospitalId(hospitalId);
  90 + patientCourseQuery.setQueryNo(queryNo);
  91 + //状态 1预约,2签到
  92 + patientCourseQuery.setStatus(1);
  93 +
  94 + List<PatientCourseResult> results = getPatientCourse(patientCourseQuery);
  95 + if (CollectionUtils.isEmpty(results))
72 96 {
73   - for (PatientCourseModel model : patientCourseModels)
  97 + PatientsQuery patientsQuery = new PatientsQuery();
  98 + patientsQuery.setYn(YnEnums.YES.getId());
  99 + patientsQuery.setPvc(queryNo);
  100 + List<Patients> patientses = patientsService.queryPatient(patientsQuery);
  101 + if (CollectionUtils.isNotEmpty(patientses))
74 102 {
  103 + Patients patients = patientses.get(0);
75 104 PatientCourseResult result = new PatientCourseResult();
76   - Patients patients = patientsService.findOnePatientById(model.getPatientId());
77 105 if (patients != null)
78 106 {
79 107 result.setAge(DateUtil.getAge(patients.getBirth(),new Date()));
80 108  
... ... @@ -81,7 +109,55 @@
81 109 result.setUserName(patients.getUsername());
82 110 result.setPhone(patients.getPhone());
83 111 result.setVcCardNo(patients.getVcCardNo());
  112 + result.setPatientId(patients.getId());
84 113 }
  114 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  115 + objectResponse.setData(result);
  116 + objectResponse.setErrorcode(ErrorCodeConstants.NO_DATA);
  117 + objectResponse.setErrormsg("该孕妇未预约此课程,是否现在预约?");
  118 + return objectResponse;
  119 + }
  120 + else
  121 + {
  122 + BaseResponse objectResponse = new BaseResponse();
  123 + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXIST);
  124 + objectResponse.setErrormsg("数据不存在");
  125 + return objectResponse;
  126 + }
  127 + }
  128 +
  129 + BaseListResponse objectResponse = new BaseListResponse();
  130 + objectResponse.setData(results);
  131 + objectResponse.setPageInfo(patientCourseQuery.getPageInfo());
  132 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  133 + objectResponse.setErrormsg("成功");
  134 + return objectResponse;
  135 + }
  136 +
  137 +
  138 + private List<PatientCourseResult> getPatientCourse(PatientCourseQuery patientCourseQuery)
  139 + {
  140 + List<PatientCourseResult> results = new ArrayList<>();
  141 + List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery);
  142 + if (CollectionUtils.isNotEmpty(patientCourseModels))
  143 + {
  144 + for (PatientCourseModel model : patientCourseModels)
  145 + {
  146 + PatientCourseResult result = new PatientCourseResult();
  147 +// Patients patients = patientsService.findOnePatientById(model.getPatientId());
  148 +// if (patients != null)
  149 +// {
  150 +// result.setAge(DateUtil.getAge(patients.getBirth(),new Date()));
  151 +// result.setCardNo(patients.getCardNo());
  152 +// result.setUserName(patients.getUsername());
  153 +// result.setPhone(patients.getPhone());
  154 +// result.setVcCardNo(patients.getVcCardNo());
  155 +// }
  156 + result.setAge(DateUtil.getAge(model.getBirthday(),new Date()));
  157 + result.setCardNo(model.getCardNo());
  158 + result.setUserName(model.getUserName());
  159 + result.setPhone(model.getPhone());
  160 + result.setVcCardNo(model.getVcCardNo());
85 161 result.setOrderTime(model.getOrderTime() == null ? "" : DateUtil.gety_m_dhm(model.getOrderTime()));
86 162 result.setSignTime(model.getSignTime() == null ? "" : DateUtil.gety_m_dhm(model.getSignTime()));
87 163 //预约类型 1 院内 2 小程序
88 164  
89 165  
... ... @@ -90,16 +166,54 @@
90 166 results.add(result);
91 167 }
92 168 }
  169 + return results;
  170 + }
93 171  
94   - BaseListResponse objectResponse = new BaseListResponse();
95   - objectResponse.setData(results);
96   - objectResponse.setPageInfo(patientCourseQuery.getPageInfo());
  172 + public BaseResponse orderCourse(String courseId, String patientId,String hospitalId,Integer orderType, Integer userId) {
  173 +
  174 + BaseResponse objectResponse = new BaseResponse();
  175 + CourseQuery query = new CourseQuery();
  176 + query.setYn(YnEnums.YES.getId());
  177 + query.setId(courseId);
  178 + List<CourseModel> courseModels = courseService.queryCourseList(query);
  179 + if (CollectionUtils.isNotEmpty(courseModels))
  180 + {
  181 + CourseModel model = courseModels.get(0);
  182 + if (model != null && model.getCourseEndTime().getTime() < new Date().getTime())
  183 + {
  184 + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE);
  185 + objectResponse.setErrormsg("该课程预约时间已截止,请刷新后重试");
  186 + return objectResponse;
  187 + }
  188 + }
  189 +
  190 + Patients patients = patientsService.findOnePatientById(patientId);
  191 + if (patients == null)
  192 + {
  193 + PatientCourseModel model = new PatientCourseModel();
  194 + model.setBirthday(patients.getBirth());
  195 + model.setCardNo(patients.getCardNo());
  196 + model.setUserName(patients.getUsername());
  197 + model.setPhone(patients.getPhone());
  198 + model.setVcCardNo(patients.getVcCardNo());
  199 + model.setOrderTime(new Date());
  200 + model.setOrderType(orderType);
  201 + model.setOperUserId(String.valueOf(userId));
  202 + model.setHospitalId(hospitalId);
  203 + model.setCourseId(courseId);
  204 + model.setCreated(new Date());
  205 + model.setModified(new Date());
  206 + model.setYn(YnEnums.YES.getId());
  207 + patientCourseService.addPatientCourse(model);
  208 + }
  209 +
97 210 objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
98 211 objectResponse.setErrormsg("成功");
99 212 return objectResponse;
100 213 }
101 214  
102   - public BaseResponse queryOrderPatient(String queryNo, Integer userId) {
  215 +
  216 + public BaseResponse querySignPatient(String queryNo, Integer userId) {
103 217 String hospitalId = autoMatchFacade.getHospitalId(userId);
104 218  
105 219 PatientCourseQuery patientCourseQuery = new PatientCourseQuery();
106 220  
107 221  
108 222  
... ... @@ -108,13 +222,92 @@
108 222 patientCourseQuery.setHospitalId(hospitalId);
109 223 patientCourseQuery.setQueryNo(queryNo);
110 224 //状态 1预约,2签到
111   - patientCourseQuery.setStatus(1);
  225 + patientCourseQuery.setStatus(2);
112 226  
113   - List<PatientCourseResult> results = new ArrayList<>();
  227 + List<PatientCourseResult> results = getPatientCourse(patientCourseQuery);
  228 + if (CollectionUtils.isEmpty(results))
  229 + {
  230 + PatientsQuery patientsQuery = new PatientsQuery();
  231 + patientsQuery.setYn(YnEnums.YES.getId());
  232 + patientsQuery.setPvc(queryNo);
  233 + List<Patients> patientses = patientsService.queryPatient(patientsQuery);
  234 + if (CollectionUtils.isNotEmpty(patientses))
  235 + {
  236 + Patients patients = patientses.get(0);
  237 + PatientCourseResult result = new PatientCourseResult();
  238 + if (patients != null)
  239 + {
  240 + result.setAge(DateUtil.getAge(patients.getBirth(),new Date()));
  241 + result.setCardNo(patients.getCardNo());
  242 + result.setUserName(patients.getUsername());
  243 + result.setPhone(patients.getPhone());
  244 + result.setVcCardNo(patients.getVcCardNo());
  245 + result.setPatientId(patients.getId());
  246 + }
  247 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  248 + objectResponse.setData(result);
  249 + objectResponse.setErrorcode(ErrorCodeConstants.NO_DATA);
  250 + objectResponse.setErrormsg("该孕妇未预约此课程,无法签到,是否现在预约?");
  251 + return objectResponse;
  252 + }
  253 + else
  254 + {
  255 + BaseResponse objectResponse = new BaseResponse();
  256 + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXIST);
  257 + objectResponse.setErrormsg("数据不存在");
  258 + return objectResponse;
  259 + }
  260 + }
114 261  
  262 + BaseListResponse objectResponse = new BaseListResponse();
  263 + objectResponse.setData(results);
  264 + objectResponse.setPageInfo(patientCourseQuery.getPageInfo());
  265 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  266 + objectResponse.setErrormsg("成功");
  267 + return objectResponse;
  268 + }
115 269  
116   - List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery);
117   - return null;
  270 + public BaseResponse signCourse(String courseId, String patientId, String hospitalId, Integer orderType, Integer userId) {
  271 +
  272 + BaseResponse objectResponse = new BaseResponse();
  273 + CourseQuery query = new CourseQuery();
  274 + query.setYn(YnEnums.YES.getId());
  275 + query.setId(courseId);
  276 + List<CourseModel> courseModels = courseService.queryCourseList(query);
  277 + if (CollectionUtils.isNotEmpty(courseModels))
  278 + {
  279 + CourseModel model = courseModels.get(0);
  280 + if (model != null && model.getCourseEndTime().getTime() < new Date().getTime())
  281 + {
  282 + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE);
  283 + objectResponse.setErrormsg("该课程预约时间已截止,请刷新后重试");
  284 + return objectResponse;
  285 + }
  286 + }
  287 +
  288 + Patients patients = patientsService.findOnePatientById(patientId);
  289 + if (patients == null)
  290 + {
  291 + PatientCourseModel model = new PatientCourseModel();
  292 + model.setBirthday(patients.getBirth());
  293 + model.setCardNo(patients.getCardNo());
  294 + model.setUserName(patients.getUsername());
  295 + model.setPhone(patients.getPhone());
  296 + model.setVcCardNo(patients.getVcCardNo());
  297 + model.setOrderTime(new Date());
  298 + model.setOrderType(orderType);
  299 + model.setOperUserId(String.valueOf(userId));
  300 + model.setHospitalId(hospitalId);
  301 + model.setCourseId(courseId);
  302 + model.setCreated(new Date());
  303 + model.setModified(new Date());
  304 + model.setYn(YnEnums.YES.getId());
  305 + patientCourseService.addPatientCourse(model);
  306 + }
  307 +
  308 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  309 + objectResponse.setErrormsg("成功");
  310 + return objectResponse;
118 311 }
119 312 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/PatientCourseResult.java View file @ 3829ae6
... ... @@ -34,6 +34,16 @@
34 34 //签到时间
35 35 private String signTime;
36 36  
  37 + private String patientId;
  38 +
  39 + public String getPatientId() {
  40 + return patientId;
  41 + }
  42 +
  43 + public void setPatientId(String patientId) {
  44 + this.patientId = patientId;
  45 + }
  46 +
37 47 public String getSignTime() {
38 48 return signTime;
39 49 }