OrderCovidExamService.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package thyyxxk.wxservice_server.service;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.beans.factory.annotation.Value;
  5. import org.springframework.stereotype.Service;
  6. import org.springframework.web.client.RestTemplate;
  7. import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
  8. import thyyxxk.wxservice_server.dao.AppointmentDao;
  9. import thyyxxk.wxservice_server.entity.ResultVo;
  10. import thyyxxk.wxservice_server.entity.assessment.CovidQuestionnaire;
  11. import thyyxxk.wxservice_server.entity.covid.OrderCovidExamParam;
  12. import thyyxxk.wxservice_server.entity.hrgresponse.SaveMzFeeResponse;
  13. import thyyxxk.wxservice_server.utils.ResultVoUtil;
  14. import thyyxxk.wxservice_server.utils.IdCardUtil;
  15. /**
  16. * @author dj
  17. */
  18. @Slf4j
  19. @Service
  20. public class OrderCovidExamService {
  21. private final AppointmentDao dao;
  22. @Value("${hrgApiUrl}")
  23. private String hrgApiUrl;
  24. @Autowired
  25. public OrderCovidExamService(AppointmentDao dao) {
  26. this.dao = dao;
  27. }
  28. public ResultVo<String> hasDoneCovidAssessment(String patientId) {
  29. CovidQuestionnaire covid = dao.validCovidAssessment(patientId);
  30. if (null == covid) {
  31. return ResultVoUtil.success("no");
  32. } else {
  33. return ResultVoUtil.success("yes");
  34. }
  35. }
  36. public ResultVo<String> savePrescription(String patientId) {
  37. RestTemplate restTemplate = new RestTemplate();
  38. String url = hrgApiUrl + "/nucleicAcidApplication?patientId=" + patientId;
  39. SaveMzFeeResponse hrgResponse = restTemplate.getForObject(url, SaveMzFeeResponse.class);
  40. log.info("快速下单核酸检测:患者:{},结果:{}", patientId, hrgResponse);
  41. if (null == hrgResponse) {
  42. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  43. }
  44. if (0 == hrgResponse.getResultCode()) {
  45. return ResultVoUtil.success();
  46. }
  47. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgResponse.getResultMessage());
  48. }
  49. public ResultVo<String> updateIdCard(String patientId, String socialNo) {
  50. log.info("更新身份证:{},{}", patientId, socialNo);
  51. dao.updateMzPatientMiSocialNo(patientId, socialNo);
  52. dao.updateWxBindSocialNo(patientId, socialNo);
  53. return ResultVoUtil.success("更新身份证成功。");
  54. }
  55. }