|
@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.wxservice_server.constant.Constants;
|
|
|
+import thyyxxk.wxservice_server.constant.Gender;
|
|
|
import thyyxxk.wxservice_server.dao.AppointmentDao;
|
|
|
import thyyxxk.wxservice_server.entity.PureCodeName;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
@@ -39,7 +40,7 @@ public class AppointmentService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<MzClass>> getAllDepartments() {
|
|
|
- if (null != mzClasses && !mzClasses.isEmpty()) {
|
|
|
+ if (ListUtil.notEmpty(mzClasses)) {
|
|
|
return ResultVoUtil.success(mzClasses);
|
|
|
}
|
|
|
log.info("重新获取门诊科室并缓存。");
|
|
@@ -202,39 +203,56 @@ public class AppointmentService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> hasValidCovidAssessment(String patientId, String deptCode) {
|
|
|
- PureCodeName sexSocial = dao.selectSexAndSocialNo(patientId);
|
|
|
- String mzClass = dao.selectMzClass(deptCode);
|
|
|
- if (Constants.Sex.MALE.equals(sexSocial.getCode()) && Constants.MzClass.GYNAECOLOGY.equals(mzClass)) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "男性无法在妇产科挂号,请选择其他科室。");
|
|
|
+ ResultVo<String> appointmentRequirements = checkAppointmentRequirements(patientId, deptCode);
|
|
|
+ if (appointmentRequirements.getCode() != ExceptionEnum.SUCCESS.getCode()) {
|
|
|
+ return appointmentRequirements;
|
|
|
}
|
|
|
- int age = IdCardUtil.calAgeBySocialNo(sexSocial.getName());
|
|
|
- if (age == -1) {
|
|
|
+ return checkCovidQuestionnaire(patientId);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ResultVo<String> checkAppointmentRequirements(String patientId, String deptCode) {
|
|
|
+ String idCard = dao.selectPatientIdCard(patientId);
|
|
|
+ if (!IdCardUtil.isValidatedIdCard(idCard)) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您在我院绑定的身份证号不是有效的身份证号," +
|
|
|
"请前往【个人中心 - 我的就诊人 - 就诊人信息】进行修改。");
|
|
|
}
|
|
|
- if (Constants.MzDept.PEDIATRICS.equals(deptCode) && age >= 18) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "成年人无法在儿科挂号,请选择其他科室。");
|
|
|
+ String mzClass = dao.selectMzClass(deptCode);
|
|
|
+ if (Constants.MzClass.GYNAECOLOGY.equals(mzClass)) {
|
|
|
+ if (IdCardUtil.getGenderByIdCard(idCard) == Gender.MALE) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "男性无法在妇产科挂号,请选择其他科室。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Constants.MzDept.PEDIATRICS.equals(deptCode)) {
|
|
|
+ if (IdCardUtil.getAgeByIdCard(idCard) >= 18) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "成年人无法在儿科挂号,请选择其他科室。");
|
|
|
+ }
|
|
|
}
|
|
|
+ return ResultVoUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ private ResultVo<String> checkCovidQuestionnaire(String patientId) {
|
|
|
CovidQuestionnaire covid = dao.validCovidAssessment(patientId);
|
|
|
if (null == covid) {
|
|
|
return ResultVoUtil.success("no valid assessment");
|
|
|
- } else {
|
|
|
- if (covid.getTemperature() == 2 ||
|
|
|
- covid.getItem1() != 14 ||
|
|
|
- covid.getItem2() != 24 ||
|
|
|
- covid.getItem3() != 32 ||
|
|
|
- covid.getItem4() != 42) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您新型冠状病毒感染流行病学史问卷未通过,请挂发热门诊。");
|
|
|
- } else {
|
|
|
- return ResultVoUtil.success("valid assessment");
|
|
|
- }
|
|
|
}
|
|
|
+ if (isDangerousCovidQuestionnaire(covid)) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您新型冠状病毒感染流行病学史问卷未通过,请挂发热门诊。");
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success("valid assessment");
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isDangerousCovidQuestionnaire(CovidQuestionnaire covid) {
|
|
|
+ return covid.getTemperature() == 2 ||
|
|
|
+ covid.getItem1() != 14 ||
|
|
|
+ covid.getItem2() != 24 ||
|
|
|
+ covid.getItem3() != 32 ||
|
|
|
+ covid.getItem4() != 42;
|
|
|
}
|
|
|
|
|
|
public ResultVo<String> getDoctorQrCode(String doctorCode) {
|
|
|
- final String token = PropertiesUtil.getProperty("qywxToken");
|
|
|
- final String url = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=" + token +
|
|
|
- "&userid=" + dao.getCodeRsByCode(doctorCode);
|
|
|
+ final String qywxToken = PropertiesUtil.getProperty("qywxToken");
|
|
|
+ final String userid = dao.selectCodeRsByCode(doctorCode);
|
|
|
+ final String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s", qywxToken, userid);
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
final String result = restTemplate.getForObject(url, String.class);
|
|
|
JSONObject json = JSONObject.parseObject(result);
|
|
@@ -244,9 +262,9 @@ public class AppointmentService {
|
|
|
public ResultVo<List<Map<String, String>>> getPaidMzGhList(String patientId) {
|
|
|
log.info("获取门诊挂号记录列表:{}", patientId);
|
|
|
RestTemplate template = new RestTemplate();
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
- obj.put("patientId", patientId);
|
|
|
- SourcesResponse hrgResponse = template.postForObject(hrgApiUrl + "/getRegistrationForPaid", obj, SourcesResponse.class);
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("patientId", patientId);
|
|
|
+ SourcesResponse hrgResponse = template.postForObject(hrgApiUrl + "/getRegistrationForPaid", params, SourcesResponse.class);
|
|
|
return ThmzUtil.getResultVoCompletableFuture(hrgResponse);
|
|
|
}
|
|
|
|