|
@@ -1,13 +1,15 @@
|
|
|
package thyyxxk.webserver.service.medicalinsurance;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
+import thyyxxk.webserver.constants.sidicts.MdtrtCertType;
|
|
|
+import thyyxxk.webserver.constants.sidicts.SiFunction;
|
|
|
import thyyxxk.webserver.dao.his.medicalinsurance.SiMzDao;
|
|
|
-import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
import thyyxxk.webserver.entity.markmtfees.*;
|
|
|
import thyyxxk.webserver.entity.medicalinsurance.outpatient.*;
|
|
@@ -19,10 +21,7 @@ import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @description: 门诊医保交易
|
|
@@ -33,12 +32,17 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class SiMzService {
|
|
|
private final SiMzDao dao;
|
|
|
+ private final ExecService exec;
|
|
|
private final ThmzSystem thmz;
|
|
|
private final SiMzSrvc mzSrvc;
|
|
|
+ private static final String RESULT_CODE = "infcode";
|
|
|
+ private static final String ERROR_MESSAGE = "err_msg";
|
|
|
+ private static final String OUTPUT = "output";
|
|
|
|
|
|
@Autowired
|
|
|
- public SiMzService(SiMzDao dao, ThmzSystem thmz, SiMzSrvc mzSrvc) {
|
|
|
+ public SiMzService(SiMzDao dao, ExecService exec, ThmzSystem thmz, SiMzSrvc mzSrvc) {
|
|
|
this.dao = dao;
|
|
|
+ this.exec = exec;
|
|
|
this.thmz = thmz;
|
|
|
this.mzSrvc = mzSrvc;
|
|
|
}
|
|
@@ -287,4 +291,69 @@ public class SiMzService {
|
|
|
public void updateMzSaved(String patientId, int times, int val) {
|
|
|
dao.updateMzSaved(patientId, times, val);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public ResultVo<List<SpcChrDiseAcct>> fetchSpcSlwinfo(String socialNo) {
|
|
|
+ if (StringUtil.isBlank(socialNo)) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者身份证号不能为空,请补充!");
|
|
|
+ }
|
|
|
+ JSONObject input = exec.makeTradeHeader(SiFunction.OBTAIN_BASIC_PERSON_INFO);
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("mdtrt_cert_type", MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
|
|
|
+ data.put("psn_cert_type", "01");
|
|
|
+ data.put("mdtrt_cert_no", socialNo);
|
|
|
+ data.put("certno", socialNo);
|
|
|
+ input.getJSONObject("input").put("data", data);
|
|
|
+ JSONObject result = exec.executeTrade(input, SiFunction.OBTAIN_BASIC_PERSON_INFO);
|
|
|
+ if (null == result) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
|
|
|
+ }
|
|
|
+ if (null == result.getInteger(RESULT_CODE)) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的慢特病备案,或慢特病备案已过期!");
|
|
|
+ }
|
|
|
+ if (result.getIntValue(RESULT_CODE) == 0) {
|
|
|
+ JSONObject output = result.getJSONObject(OUTPUT);
|
|
|
+ JSONObject baseinfo = output.getJSONObject("baseinfo");
|
|
|
+ String psnNo = baseinfo.getString("psn_no");
|
|
|
+ JSONArray insuinfo = output.getJSONArray("insuinfo");
|
|
|
+ Date now = new Date();
|
|
|
+ List<SpcChrDiseAcct> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < insuinfo.size(); i++) {
|
|
|
+ JSONObject item = insuinfo.getJSONObject(i);
|
|
|
+ String admdvs = item.getString("insuplc_admdvs");
|
|
|
+ input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_ACCREDITATION, admdvs);
|
|
|
+ data = new JSONObject();
|
|
|
+ data.put("psn_no", psnNo);
|
|
|
+ input.getJSONObject("input").put("data", data);
|
|
|
+ result = exec.executeTrade(input, SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_ACCREDITATION);
|
|
|
+ if (null == result) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (null == result.getInteger(RESULT_CODE)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (result.getIntValue(RESULT_CODE) == 0) {
|
|
|
+ output = result.getJSONObject(OUTPUT);
|
|
|
+ JSONArray details = output.getJSONArray("feedetail");
|
|
|
+ if (null == details || details.size() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (int j = 0; j < details.size(); j++) {
|
|
|
+ JSONObject detail = details.getJSONObject(j);
|
|
|
+ SpcChrDiseAcct spcChrDiseAcct = JSONObject.parseObject(detail.toJSONString(), SpcChrDiseAcct.class);
|
|
|
+ if (now.before(spcChrDiseAcct.getEnddate())) {
|
|
|
+ list.add(spcChrDiseAcct);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (list.size() > 0) {
|
|
|
+ return ResultVoUtil.success(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的慢特病备案,或慢特病备案已过期!");
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的慢特病备案,或慢特病备案已过期!");
|
|
|
+ }
|
|
|
+
|
|
|
}
|