|
@@ -1,11 +1,22 @@
|
|
package thyyxxk.wxservice_server.service;
|
|
package thyyxxk.wxservice_server.service;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
+import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
|
|
|
|
+import thyyxxk.wxservice_server.constant.medins.FundDetail;
|
|
|
|
+import thyyxxk.wxservice_server.constant.medins.Insutype;
|
|
|
|
+import thyyxxk.wxservice_server.constant.medins.MedType;
|
|
|
|
+import thyyxxk.wxservice_server.dao.PayMzFeeDao;
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
|
+import thyyxxk.wxservice_server.entity.paymzfee.MedinsPresettle;
|
|
import thyyxxk.wxservice_server.factory.thmz.ThmzService;
|
|
import thyyxxk.wxservice_server.factory.thmz.ThmzService;
|
|
import thyyxxk.wxservice_server.factory.thmz.model.QueryReceiptRequest;
|
|
import thyyxxk.wxservice_server.factory.thmz.model.QueryReceiptRequest;
|
|
|
|
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -18,11 +29,15 @@ import java.util.Map;
|
|
public class PayMzFeeService {
|
|
public class PayMzFeeService {
|
|
private final ElectronicHealthCardService healthCardService;
|
|
private final ElectronicHealthCardService healthCardService;
|
|
private final ThmzService thmzService;
|
|
private final ThmzService thmzService;
|
|
|
|
+ private final PayMzFeeDao dao;
|
|
|
|
+ @Value("${siMzApiUrl}")
|
|
|
|
+ private String siMzApiUrl;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- public PayMzFeeService(ElectronicHealthCardService healthCardService, ThmzService thmzService) {
|
|
|
|
|
|
+ public PayMzFeeService(ElectronicHealthCardService healthCardService, ThmzService thmzService, PayMzFeeDao dao) {
|
|
this.healthCardService = healthCardService;
|
|
this.healthCardService = healthCardService;
|
|
this.thmzService = thmzService;
|
|
this.thmzService = thmzService;
|
|
|
|
+ this.dao = dao;
|
|
}
|
|
}
|
|
|
|
|
|
public ResultVo<List<Map<String, Object>>> getUnPaidFee(String patientId) {
|
|
public ResultVo<List<Map<String, Object>>> getUnPaidFee(String patientId) {
|
|
@@ -50,4 +65,42 @@ public class PayMzFeeService {
|
|
return thmzService.getMzPaidDetail(request);
|
|
return thmzService.getMzPaidDetail(request);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public ResultVo<String> getUnsettledMdtrtId(String hisOrdNum) {
|
|
|
|
+ String[] hisOrdNumSplitArray = hisOrdNum.split("_");
|
|
|
|
+ String patNo = hisOrdNumSplitArray[0];
|
|
|
|
+ int times = Integer.parseInt(hisOrdNumSplitArray[1]);
|
|
|
|
+ String mdtrtId = dao.selectUnsettledMdtrtId(patNo, times);
|
|
|
|
+ if (null == mdtrtId) {
|
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.CONTINUE_NEXT_STEP);
|
|
|
|
+ }
|
|
|
|
+ int settledCount = dao.selectSettledCount(mdtrtId);
|
|
|
|
+ if (settledCount == 1) {
|
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.CONTINUE_NEXT_STEP);
|
|
|
|
+ }
|
|
|
|
+ return ResultVoUtil.success(mdtrtId);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ResultVo<MedinsPresettle> getUnsettledMedinsTrade(String mdtrtId) {
|
|
|
|
+ MedinsPresettle presettle = dao.selectMedinsPresettle(mdtrtId);
|
|
|
|
+ if (null == presettle) {
|
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
|
|
|
|
+ }
|
|
|
|
+ presettle.setInsutypeName(Insutype.getName(presettle.getInsutype()));
|
|
|
|
+ presettle.setMedTypeName(MedType.getName(presettle.getMedType()));
|
|
|
|
+ return ResultVoUtil.success(presettle);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ResultVo<FundDetail> medinsSettle(MedinsPresettle presettle) {
|
|
|
|
+ String url = siMzApiUrl + "/outpatientSettlement";
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ params.put("patNo", presettle.getPatNo());
|
|
|
|
+ params.put("times", presettle.getTimes());
|
|
|
|
+ params.put("acctUsedFlag", presettle.getAcctUsedFlag());
|
|
|
|
+ params.put("staffId", "99999");
|
|
|
|
+ RestTemplate template = new RestTemplate();
|
|
|
|
+ ResultVo<FundDetail> response = template.postForObject(url, params, ResultVo.class);
|
|
|
|
+ log.info("患者自助医保结算:\n参数:{}\n结果:{}", params, JSON.toJSON(response));
|
|
|
|
+ return response;
|
|
|
|
+ }
|
|
}
|
|
}
|