lighter пре 1 година
родитељ
комит
0867f1a10d

+ 1 - 0
src/main/java/thyyxxk/wxservice_server/config/exception/ExceptionEnum.java

@@ -24,6 +24,7 @@ public enum ExceptionEnum {
      * 以下是不需要提示的错误
      * */
     SLIGHTLY_ERROR(4001, "不需要提示的错误。"),
+    CONTINUE_NEXT_STEP(4002, ""),
     /**
      * 以下是内部使用的错误
      * */

+ 17 - 0
src/main/java/thyyxxk/wxservice_server/constant/medins/FundDetail.java

@@ -0,0 +1,17 @@
+package thyyxxk.wxservice_server.constant.medins;
+
+import lombok.Data;
+
+/**
+ * @description: 试算、结算报销
+ * @author: DingJie
+ * @create: 2021/7/2011:31
+ */
+@Data
+public class FundDetail {
+    private String totalCost;
+    private String fundPay;
+    private String acctPay;
+    private String cashPay;
+    private String selfPay;
+}

+ 79 - 0
src/main/java/thyyxxk/wxservice_server/constant/medins/Insutype.java

@@ -0,0 +1,79 @@
+package thyyxxk.wxservice_server.constant.medins;
+
+import thyyxxk.wxservice_server.utils.StringUtil;
+
+/**
+ * @description: 险种类型
+ * @author: DingJie
+ * @create: 2021/7/129:12
+ */
+public enum Insutype {
+
+    BASIC_MEDICAL_INSURANCE_FOR_EMPLOYEES("310", "职工基本医疗保险"),
+
+    MEDICAID_FOR_CIVIL_SERVANTS("320", "公务员医疗补助"),
+
+    LARGE_MEDICAL_EXPENSES_SUBSIDY("330", "大额医疗费用补助"),
+
+    MEDICAL_SECURITY_FOR_RETIRED_PERSONNEL("340", "离休人员医疗保障"),
+
+    MEDICAID_FOR_DISABLED_SOLDIERS("350", "一至六级残废军人医疗补助"),
+
+    MEDICAID_FOR_ELDERLY_RED_ARMY("360", "老红军医疗保障"),
+
+    ENTERPRISE_SUPPLEMENTARY_MEDICAL_INSURANCE("370", "企业补充医疗保险"),
+
+    NEW_RURAL_COOPERATIVE_MEDICAL_SYSTEM("380", "新型农村合作医疗"),
+
+    BASIC_MEDICAL_INSURANCE_FOR_RURAL_RESIDENTS("390", "城乡居民基本医疗保险"),
+
+    BASIC_MEDICAL_INSURANCE_FOR_URBAN_RESIDENTS("391", "城镇居民基本医疗保险"),
+
+    SERIOUS_ILLNESS_MEDICAL_INSURANCE_FOR_URBAN_AND_RURAL_RESIDENTS("392", "城乡居民大病医疗保险"),
+
+    MEDICAL_SECURITY_FOR_OTHER_SPECIAL_PERSONNEL("399", "其他特殊人员医疗保障"),
+
+    LONG_TERM_CARE_INSURANCE("410", "长期照护保险"),
+
+    MATERNITY_INSURANCE("510", "生育保险");
+
+    private final String code;
+    private final String name;
+
+    Insutype(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static Insutype get(String code) {
+        if (StringUtil.isBlank(code)) {
+            return null;
+        }
+        for (Insutype insutype : Insutype.values()) {
+            if (code.trim().equals(insutype.getCode())) {
+                return insutype;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(String code) {
+        if (StringUtil.isBlank(code)) {
+            return null;
+        }
+        for (Insutype insutype : Insutype.values()) {
+            if (code.trim().equals(insutype.getCode())) {
+                return insutype.getName();
+            }
+        }
+        return null;
+    }
+}

+ 101 - 0
src/main/java/thyyxxk/wxservice_server/constant/medins/MedType.java

@@ -0,0 +1,101 @@
+package thyyxxk.wxservice_server.constant.medins;
+
+import thyyxxk.wxservice_server.utils.StringUtil;
+
+/**
+ * @description: 医疗类别
+ * @author: DingJie```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
+ * @create: 2021/7/1010:59
+ */
+public enum MedType {
+
+    SELF_PAY("01", "自费", "hospitalization", "01"),
+
+    GENERAL_CLINIC("11", "普通门诊", "clinic", "aa"),
+
+    EMERGENCY_TREATMENT("13", "急诊", "clinic", "ab"),
+
+    EMERGENCY_TREATMENT_RESCUE("1301", "急诊抢救", "clinic", "ab1"),
+
+    OUTPATIENT_CHRONIC_IDIOPATHIC_DISEASES("14", "门诊慢特病", "clinic", "ac"),
+
+    GENERAL_HOSPITALIZATION("2101", "普通住院", "hospitalization", "ad"),
+
+    SINGLE_DISEASE_HOSPITALIZATION("2102", "单病种住院", "hospitalization", "ae"),
+
+    RESIDENTS_NORMAL_BIRTH("2106", "生育平产(居民)", "hospitalization", "af"),
+
+    RESIDENTS_BIRTH_CESAREAN_SECTION("2107", "生育剖宫产(居民)", "hospitalization", "ag"),
+
+    TRAUMA_HOSPITALIZATION("22", "外伤住院", "hospitalization", "ah"),
+
+    DESIGNATED_DRUGSTORES_PURCHASE("41", "定点药店购药", "drug", "ai"),
+
+    MATERNITY_CLINIC("51", "生育门诊", "clinic", "aj"),
+
+    MATERNITY_HOSPITALIZATION("52", "生育住院", "hospitalization", "ak"),
+
+    INJURY_HOSPITALIZATION("42", "工伤住院", "hospitalization", "al"),
+
+    OCCUPATIONAL_INJURY_CLINIC("41", "工伤门诊", "clinic", "al1"),
+
+    INJURY_RECOVER_CLINIC("46", "康复门诊", "clinic", "al2"),
+
+    OUTPATIENT_TWO_DISEASES("9901", "门诊两病", "clinic", "am"),
+
+    ACCIDENTAL_INJURY_CLINIC("9903", "意外伤害门诊", "clinic", "an"),
+
+    SPECIAL_MEDICINE_FOR_SERIOUS_ILLNESS("9904", "大病特药", "clinic", "ao");
+
+    private final String code;
+    private final String name;
+    private final String flag;
+    private final String responceType;
+
+    MedType(String code, String name, String flag, String responceType) {
+        this.code = code;
+        this.name = name;
+        this.flag = flag;
+        this.responceType = responceType;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getFlag() {
+        return flag;
+    }
+
+    public String getResponceType() {
+        return responceType;
+    }
+
+    public static MedType get(String code) {
+        if (StringUtil.isBlank(code)) {
+            return null;
+        }
+        for (MedType medType : MedType.values()) {
+            if (code.trim().equals(medType.getCode())) {
+                return medType;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(String code) {
+        if (StringUtil.isBlank(code)) {
+            return SELF_PAY.getName();
+        }
+        for (MedType medType : MedType.values()) {
+            if (code.trim().equals(medType.getCode())) {
+                return medType.getName();
+            }
+        }
+        return SELF_PAY.getName();
+    }
+}

+ 19 - 4
src/main/java/thyyxxk/wxservice_server/controller/PayMzFeeController.java

@@ -1,11 +1,10 @@
 package thyyxxk.wxservice_server.controller;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.wxservice_server.constant.medins.FundDetail;
 import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.paymzfee.MedinsPresettle;
 import thyyxxk.wxservice_server.service.PayMzFeeService;
 
 import java.util.List;
@@ -40,8 +39,24 @@ public class PayMzFeeController {
         return service.getMzPaidList(patientId);
     }
 
+    @GetMapping("/getUnsettledMdtrtId")
+    public ResultVo<String> getUnsettledMdtrtId(@RequestParam("hisOrdNum") String hisOrdNum) {
+        return service.getUnsettledMdtrtId(hisOrdNum);
+    }
+
+    @GetMapping("/getUnsettledMedinsTrade")
+    public ResultVo<MedinsPresettle> getUnsettledMedinsTrade(@RequestParam("mdtrtId") String mdtrtId) {
+        return service.getUnsettledMedinsTrade(mdtrtId);
+    }
+
+    @PostMapping("/medinsSettle")
+    public ResultVo<FundDetail> medinsSettle(@RequestBody MedinsPresettle presettle) {
+        return service.medinsSettle(presettle);
+    }
+
     @GetMapping("/getMzPaidDetail")
     public ResultVo<List<Map<String, Object>>> getMzPaidDetail(@RequestParam("hisOrdNum") String hisOrdNum) {
         return service.getMzPaidDetail(hisOrdNum);
     }
+
 }

+ 18 - 0
src/main/java/thyyxxk/wxservice_server/dao/PayMzFeeDao.java

@@ -0,0 +1,18 @@
+package thyyxxk.wxservice_server.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.wxservice_server.entity.paymzfee.MedinsPresettle;
+
+@Mapper
+public interface PayMzFeeDao {
+
+    @Select("select mdtrt_id from t_si_presetlinfo where pat_no=#{patNo} and times=#{times}")
+    String selectUnsettledMdtrtId(String patNo, int times);
+
+    @Select("select * from t_si_presetlinfo where mdtrt_id=#{mdtrtId} ")
+    MedinsPresettle selectMedinsPresettle(String mdtrtId);
+
+    @Select("select count(1) from t_si_setlinfo where mdtrt_id=#{mdtrtId} and revoked=0")
+    int selectSettledCount(String mdtrtId);
+}

+ 227 - 0
src/main/java/thyyxxk/wxservice_server/entity/paymzfee/MedinsPresettle.java

@@ -0,0 +1,227 @@
+package thyyxxk.wxservice_server.entity.paymzfee;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class MedinsPresettle implements Serializable {
+
+	private static final long serialVersionUID =  6876991080910479303L;
+
+	/**
+	 * 住院号/门诊号
+	 */
+	private String patNo;
+
+	/**
+	 * 住院次数/门诊次数
+	 */
+	private Integer times;
+
+	/**
+	 * 账页号(门诊为receiptNo)
+	 */
+	private Integer ledgerSn;
+
+	/**
+	 * 就诊ID
+	 */
+	private String mdtrtId;
+
+	/**
+	 * 人员编号
+	 */
+	private String psnNo;
+
+	/**
+	 * 人员姓名
+	 */
+	private String psnName;
+
+	/**
+	 * 人员证件类型
+	 */
+	private String psnCertType;
+
+	/**
+	 * 证件号码
+	 */
+	private String certno;
+
+	/**
+	 * 性别
+	 */
+	private String gend;
+
+	/**
+	 * 民族
+	 */
+	private String naty;
+
+	/**
+	 * 出生日期
+	 */
+	@DateTimeFormat(pattern = "yyyy-MM-dd")
+	@JsonFormat(pattern = "yyyy-MM-dd")
+	private Date brdy;
+
+	/**
+	 * 年龄
+	 */
+	private String age;
+
+	/**
+	 * 险种类型
+	 */
+	private String insutype;
+
+	/**
+	 * 人员类别
+	 */
+	private String psnType;
+
+	/**
+	 * 公务员标志
+	 */
+	private String cvlservFlag;
+
+	/**
+	 * 结算时间
+	 */
+	private Date setlTime;
+
+	/**
+	 * 就诊凭证类型
+	 */
+	private String mdtrtCertType;
+
+	/**
+	 * 医疗类别
+	 */
+	private String medType;
+
+	/**
+	 * 医疗费总额
+	 */
+	private String medfeeSumamt;
+
+	/**
+	 * 全自费金额
+	 */
+	private String fulamtOwnpayAmt;
+
+	/**
+	 * 超限价自费费用
+	 */
+	private String overlmtSelfpay;
+
+	/**
+	 * 先行自付金额
+	 */
+	private String preselfpayAmt;
+
+	/**
+	 * 符合政策范围金额
+	 */
+	private String inscpScpAmt;
+
+	/**
+	 * 实际支付起付线
+	 */
+	private String actPayDedc;
+
+	/**
+	 * 基本医疗保险统筹基金支出
+	 */
+	private String hifpPay;
+
+	/**
+	 * 基本医疗保险统筹基金支付比例
+	 */
+	private String poolPropSelfpay;
+
+	/**
+	 * 公务员医疗补助资金支出
+	 */
+	private String cvlservPay;
+
+	/**
+	 * 企业补充医疗保险基金支出
+	 */
+	private String hifesPay;
+
+	/**
+	 * 居民大病保险资金支出
+	 */
+	private String hifmiPay;
+
+	/**
+	 * 职工大额医疗费用补助基金支出
+	 */
+	private String hifobPay;
+
+	/**
+	 * 医疗救助基金支出
+	 */
+	private String mafPay;
+
+	/**
+	 * 医院负担金额
+	 */
+	private String hospPartAmt;
+
+	/**
+	 * 其他支出
+	 */
+	private String othPay;
+
+	/**
+	 * 基金支付总额
+	 */
+	private String fundPaySumamt;
+
+	/**
+	 * 个人负担总金额
+	 */
+	private String psnPartAmt;
+
+	/**
+	 * 个人账户支出
+	 */
+	private String acctPay;
+
+	/**
+	 * 个人现金支出
+	 */
+	private String psnCashPay;
+
+	/**
+	 * 余额
+	 */
+	private String balc;
+
+	/**
+	 * 个人账户共济支付金额
+	 */
+	private String acctMulaidPay;
+
+	/**
+	 * 医药机构结算ID
+	 */
+	private String medinsSetlId;
+
+	/**
+	 * 业务开始时间
+	 * */
+	private Date createTime;
+
+	private String gendName;
+	private String insutypeName;
+	private String psnTypeName;
+	private String medTypeName;
+	private String acctUsedFlag;
+}

+ 54 - 1
src/main/java/thyyxxk/wxservice_server/service/PayMzFeeService.java

@@ -1,11 +1,22 @@
 package thyyxxk.wxservice_server.service;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 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.paymzfee.MedinsPresettle;
 import thyyxxk.wxservice_server.factory.thmz.ThmzService;
 import thyyxxk.wxservice_server.factory.thmz.model.QueryReceiptRequest;
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
 
 import java.util.List;
 import java.util.Map;
@@ -18,11 +29,15 @@ import java.util.Map;
 public class PayMzFeeService {
     private final ElectronicHealthCardService healthCardService;
     private final ThmzService thmzService;
+    private final PayMzFeeDao dao;
+    @Value("${siMzApiUrl}")
+    private String siMzApiUrl;
 
     @Autowired
-    public PayMzFeeService(ElectronicHealthCardService healthCardService, ThmzService thmzService) {
+    public PayMzFeeService(ElectronicHealthCardService healthCardService, ThmzService thmzService, PayMzFeeDao dao) {
         this.healthCardService = healthCardService;
         this.thmzService = thmzService;
+        this.dao = dao;
     }
 
     public ResultVo<List<Map<String, Object>>> getUnPaidFee(String patientId) {
@@ -50,4 +65,42 @@ public class PayMzFeeService {
         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;
+    }
 }

+ 1 - 0
src/main/resources/application-8083.yml

@@ -69,6 +69,7 @@ management:
     prometheus:
       enabled: true
 
+siMzApiUrl: http://172.16.32.166:1100/mzFee
 hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 appletThmzUrl: http://172.16.32.160:81/thmz
 chronicUrl: http://172.16.32.160:8077/chronicDisease

+ 1 - 0
src/main/resources/application-8085.yml

@@ -70,6 +70,7 @@ management:
     prometheus:
       enabled: true
 
+siMzApiUrl: http://172.16.32.166:1100/mzFee
 hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 appletThmzUrl: http://172.16.32.160:81/thmz
 chronicUrl: http://172.16.32.160:8077/chronicDisease

+ 4 - 3
src/main/resources/application.yml

@@ -70,9 +70,10 @@ management:
     prometheus:
       enabled: true
 
-hrgApiUrl: http://172.16.30.22:8089/thmz/api/v1
-appletThmzUrl: http://172.16.30.22:8089/thmz
-chronicUrl: http://172.16.30.26:8706/chronicDisease
+siMzApiUrl: http://172.16.30.26:1100/mzFee
+hrgApiUrl: http://demo.hnthyy.cn:8089/thmz/api/v1
+appletThmzUrl: http://demo.hnthyy.cn:8089/thmz
+chronicUrl: http://demo.hnthyy.cn:8706/chronicDisease
 #hrgApiUrl: http://172.16.32.160:81/thmz/api/v1
 #appletThmzUrl: http://172.16.32.160:81/thmz