|
@@ -9,18 +9,10 @@ import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.wxservice_server.dao.AppointmentDao;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
-import thyyxxk.wxservice_server.entity.assessment.CovidQuestionnaire;
|
|
|
import thyyxxk.wxservice_server.entity.bookable.BookedYjReq;
|
|
|
import thyyxxk.wxservice_server.entity.bookable.Prescription;
|
|
|
-import thyyxxk.wxservice_server.entity.covid.MultipleExamTimeLimit;
|
|
|
import thyyxxk.wxservice_server.entity.hrgresponse.SaveMzFeeResponse;
|
|
|
-import thyyxxk.wxservice_server.utils.CastUtil;
|
|
|
import thyyxxk.wxservice_server.utils.ResultVoUtil;
|
|
|
-import thyyxxk.wxservice_server.utils.StringUtil;
|
|
|
-
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author dj
|
|
@@ -29,7 +21,6 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class OrderCovidExamService {
|
|
|
private final AppointmentDao dao;
|
|
|
- private final MultipleExamTimeLimit timeLimit = new MultipleExamTimeLimit();
|
|
|
private static Boolean CHECK_MAX_COVID_ANTIGEN = true;
|
|
|
private static Integer MAX_COVID_ANTIGEN = 100;
|
|
|
|
|
@@ -46,39 +37,11 @@ public class OrderCovidExamService {
|
|
|
MAX_COVID_ANTIGEN = maxCount;
|
|
|
}
|
|
|
|
|
|
- public ResultVo<String> hasDoneCovidAssessment(String patientId) {
|
|
|
- CovidQuestionnaire covid = dao.validCovidAssessment(patientId);
|
|
|
- if (null == covid) {
|
|
|
- return ResultVoUtil.success("no");
|
|
|
- } else {
|
|
|
- return ResultVoUtil.success("yes");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public ResultVo<String> savePrescription(String patientId, int type) {
|
|
|
- if (type == 2) {
|
|
|
- if (CHECK_MAX_COVID_ANTIGEN && dao.reqCount("004651") >= MAX_COVID_ANTIGEN) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "今日新冠抗原检测已售罄,无法继续下单,敬请谅解。");
|
|
|
- }
|
|
|
- int regNoExist = dao.regNoExist(patientId);
|
|
|
- if (regNoExist == 0) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您今日没有有效的挂号信息,无法继续下单,敬请谅解。");
|
|
|
- }
|
|
|
- int reqNoExist = dao.reqNoExist(patientId, "004651");
|
|
|
- if (reqNoExist > 0) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您今日已经下单过新型冠状病毒抗原检测,无法继续下单,敬请谅解。");
|
|
|
- }
|
|
|
- BookedYjReq req = new BookedYjReq();
|
|
|
- req.setPatientId(patientId);
|
|
|
- req.setCode("004651");
|
|
|
- req.setName("新型冠状病毒抗原检测");
|
|
|
- return orderCovidAntigen(req);
|
|
|
- }
|
|
|
- String[] oris = getExamUrlAndLabel(type);
|
|
|
+ public ResultVo<String> applySingleCovidExam(String patientId) {
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
|
- String url = hrgApiUrl + oris[0] + patientId;
|
|
|
+ String url = hrgApiUrl + "/nucleicAcidApplication?patientId=" + patientId;
|
|
|
SaveMzFeeResponse hrgResponse = restTemplate.getForObject(url, SaveMzFeeResponse.class);
|
|
|
- log.info("【{}】快速下单核酸检测:患者:{},结果:{}", oris[1], patientId, hrgResponse);
|
|
|
+ log.info("【单人单管】快速下单核酸检测:患者:{},结果:{}", patientId, hrgResponse);
|
|
|
if (null == hrgResponse) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
|
|
|
}
|
|
@@ -88,14 +51,23 @@ public class OrderCovidExamService {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgResponse.getResultMessage());
|
|
|
}
|
|
|
|
|
|
- private String[] getExamUrlAndLabel(int type) {
|
|
|
- switch (type) {
|
|
|
- case 1:
|
|
|
- return new String[]{"/nucleicAcidApplication?patientId=", "单人单管(绿码)"};
|
|
|
- case 3:
|
|
|
- default:
|
|
|
- return new String[]{"/nucleicOnlyYellowAcidApplication?patientId=", "单人单管(黄码)"};
|
|
|
+ public ResultVo<String> applyCovidAntigen(String patientId) {
|
|
|
+ if (CHECK_MAX_COVID_ANTIGEN && dao.reqCount("004651") >= MAX_COVID_ANTIGEN) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "今日新冠抗原检测已售罄,无法继续下单,敬请谅解。");
|
|
|
+ }
|
|
|
+ int regNoExist = dao.regNoExist(patientId);
|
|
|
+ if (regNoExist == 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您今日没有有效的挂号信息,无法继续下单,敬请谅解。");
|
|
|
}
|
|
|
+ int reqNoExist = dao.reqNoExist(patientId, "004651");
|
|
|
+ if (reqNoExist > 0) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您今日已经下单过新型冠状病毒抗原检测,无法继续下单,敬请谅解。");
|
|
|
+ }
|
|
|
+ BookedYjReq req = new BookedYjReq();
|
|
|
+ req.setPatientId(patientId);
|
|
|
+ req.setCode("004651");
|
|
|
+ req.setName("新型冠状病毒抗原检测");
|
|
|
+ return orderCovidAntigen(req);
|
|
|
}
|
|
|
|
|
|
private ResultVo<String> orderCovidAntigen(BookedYjReq param) {
|
|
@@ -118,49 +90,4 @@ public class OrderCovidExamService {
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
|
|
|
|
- public ResultVo<MultipleExamTimeLimit> getMultipleExamTimeLimit() {
|
|
|
- if (StringUtil.isBlank(timeLimit.getLimitValue())) {
|
|
|
- timeLimitChanged();
|
|
|
- }
|
|
|
- return ResultVoUtil.success(timeLimit);
|
|
|
- }
|
|
|
-
|
|
|
- public String timeLimitChanged() {
|
|
|
- String url = hrgApiUrl + "/getHyBirdTime";
|
|
|
- RestTemplate template = new RestTemplate();
|
|
|
- Map<String, Object> result = template.getForObject(url, HashMap.class);
|
|
|
- log.info("重新获取混检开放时间:{}", result);
|
|
|
- if (null == result) {
|
|
|
- String msg = "获取混检开放时间失败,接口返回空。";
|
|
|
- log.info(msg);
|
|
|
- return msg;
|
|
|
- }
|
|
|
- if ((int) result.get("code") != 0) {
|
|
|
- String msg = result.get("message").toString();
|
|
|
- log.info("获取混检开放时间失败:{}", msg);
|
|
|
- return msg;
|
|
|
- }
|
|
|
- Map<String, String> data = CastUtil.cast(result.get("data"));
|
|
|
- String value = data.get("configValue");
|
|
|
- String[] valuesArr = value.replaceAll(":", "").split("-");
|
|
|
- timeLimit.setLimitValue(value);
|
|
|
- timeLimit.setLimitValueForDisplay(value.replace("-", " - "));
|
|
|
- timeLimit.setBeginLimit(Integer.parseInt(valuesArr[0]));
|
|
|
- timeLimit.setEndLimit(Integer.parseInt(valuesArr[1]));
|
|
|
- return JSONObject.toJSONString(timeLimit);
|
|
|
- }
|
|
|
-
|
|
|
- public ResultVo<String> yellowHealthCardFreeCovidExam(String patientId) {
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String url = hrgApiUrl + "/nucleicOnlyYellowAcidApplication?patientId=" + patientId;
|
|
|
- SaveMzFeeResponse hrgResponse = restTemplate.getForObject(url, SaveMzFeeResponse.class);
|
|
|
- log.info("黄码免费核酸检测快速下单:患者:{},结果:{}", patientId, hrgResponse);
|
|
|
- if (null == hrgResponse) {
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "网络异常,请稍后再试。");
|
|
|
- }
|
|
|
- if (0 == hrgResponse.getResultCode()) {
|
|
|
- return ResultVoUtil.success("黄码免费核酸检测下单成功。");
|
|
|
- }
|
|
|
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgResponse.getResultMessage());
|
|
|
- }
|
|
|
}
|