feat(yb): 添加医保模拟服务和控制器
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package com.healthlink.his.web.ybmock.controller;
|
||||
|
||||
import com.healthlink.his.yb.mock.domain.YbPsnInfo;
|
||||
import com.healthlink.his.yb.mock.service.YbMockService;
|
||||
import com.core.common.core.domain.R;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 医保模拟接口 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/yb-mock")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "医保模拟接口")
|
||||
public class YbMockController {
|
||||
|
||||
private final YbMockService ybMockService;
|
||||
|
||||
@PostMapping("/{apiCode}")
|
||||
@Operation(summary = "医保模拟接口")
|
||||
public R<?> handleApi(@PathVariable String apiCode, @RequestBody Map<String, String> params) {
|
||||
log.info("收到医保请求: apiCode={}, params={}", apiCode, params);
|
||||
try {
|
||||
Map<String, Object> result;
|
||||
switch (apiCode) {
|
||||
case "1101":
|
||||
result = ybMockService.getPatientInfo(params);
|
||||
break;
|
||||
case "2201":
|
||||
result = ybMockService.clinicRegister(params);
|
||||
break;
|
||||
case "2203":
|
||||
result = ybMockService.clinicPrescription(params);
|
||||
break;
|
||||
case "2207":
|
||||
result = ybMockService.clinicSettle(params);
|
||||
break;
|
||||
case "3201":
|
||||
result = ybMockService.inpatientRegister(params);
|
||||
break;
|
||||
case "3203":
|
||||
result = ybMockService.inpatientPrescription(params);
|
||||
break;
|
||||
case "3207":
|
||||
result = ybMockService.inpatientSettle(params);
|
||||
break;
|
||||
default:
|
||||
result = new HashMap<>();
|
||||
result.put("infcode", -1);
|
||||
result.put("err_msg", "未支持的接口: " + apiCode);
|
||||
}
|
||||
return R.ok(result);
|
||||
} catch (Exception e) {
|
||||
log.error("医保接口调用失败", e);
|
||||
Map<String, Object> error = new HashMap<>();
|
||||
error.put("infcode", -1);
|
||||
error.put("err_msg", "系统错误: " + e.getMessage());
|
||||
return R.ok(error);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/psn/{psnNo}")
|
||||
@Operation(summary = "获取参保人信息")
|
||||
public R<?> getPatientInfo(@PathVariable String psnNo) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("psn_no", psnNo);
|
||||
return R.ok(ybMockService.getPatientInfo(params));
|
||||
}
|
||||
|
||||
@PostMapping("/psn")
|
||||
@Operation(summary = "添加参保人信息")
|
||||
public R<?> addPsnInfo(@RequestBody YbPsnInfo psnInfo) {
|
||||
return R.ok(ybMockService.addPsnInfo(psnInfo));
|
||||
}
|
||||
|
||||
@GetMapping("/psn/list")
|
||||
@Operation(summary = "获取参保人列表")
|
||||
public R<?> listPsnInfo() {
|
||||
return R.ok(ybMockService.listPsnInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.healthlink.his.yb.mock.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.healthlink.his.yb.mock.domain.YbPsnInfo;
|
||||
import com.healthlink.his.yb.mock.mapper.YbPsnInfoMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 医保模拟服务
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class YbMockService {
|
||||
|
||||
@Autowired
|
||||
private YbPsnInfoMapper psnInfoMapper;
|
||||
|
||||
public Map<String, Object> getPatientInfo(Map<String, String> params) {
|
||||
String psnNo = params.get("psn_no");
|
||||
log.info("获取参保人信息: psnNo={}", psnNo);
|
||||
|
||||
YbPsnInfo psnInfo = psnInfoMapper.selectOne(
|
||||
new LambdaQueryWrapper<YbPsnInfo>().eq(YbPsnInfo::getPsnNo, psnNo)
|
||||
);
|
||||
|
||||
if (psnInfo == null) {
|
||||
Map<String, Object> error = new HashMap<>();
|
||||
error.put("infcode", -1);
|
||||
error.put("err_msg", "未找到参保人信息: " + psnNo);
|
||||
return error;
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("infcode", 0);
|
||||
result.put("output", buildPsnInfoOutput(psnInfo));
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> clinicRegister(Map<String, String> params) {
|
||||
log.info("门诊登记: params={}", params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("infcode", 0);
|
||||
Map<String, Object> output = new HashMap<>();
|
||||
output.put("encounter_no", "MZ" + System.currentTimeMillis());
|
||||
output.put("register_time", new Date().toString());
|
||||
output.put("status", "成功");
|
||||
result.put("output", output);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> clinicPrescription(Map<String, String> params) {
|
||||
log.info("门诊处方上传: params={}", params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("infcode", 0);
|
||||
Map<String, Object> output = new HashMap<>();
|
||||
output.put("recipe_no", "CF" + System.currentTimeMillis());
|
||||
output.put("upload_time", new Date().toString());
|
||||
output.put("total_amount", "156.80");
|
||||
output.put("self_pay", "23.52");
|
||||
output.put("insurance_pay", "133.28");
|
||||
output.put("status", "成功");
|
||||
result.put("output", output);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> clinicSettle(Map<String, String> params) {
|
||||
log.info("门诊结算: params={}", params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("infcode", 0);
|
||||
Map<String, Object> output = new HashMap<>();
|
||||
output.put("settle_no", "JZ" + System.currentTimeMillis());
|
||||
output.put("total_amount", "156.80");
|
||||
output.put("insurance_pay", "133.28");
|
||||
output.put("self_pay", "23.52");
|
||||
output.put("account_pay", "20.00");
|
||||
output.put("cash_pay", "3.52");
|
||||
output.put("settle_time", new Date().toString());
|
||||
output.put("status", "成功");
|
||||
result.put("output", output);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> inpatientRegister(Map<String, String> params) {
|
||||
log.info("住院登记: params={}", params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("infcode", 0);
|
||||
Map<String, Object> output = new HashMap<>();
|
||||
output.put("admission_no", "ZY" + System.currentTimeMillis());
|
||||
output.put("admission_time", new Date().toString());
|
||||
output.put("bed_no", "3-201-1");
|
||||
output.put("status", "成功");
|
||||
result.put("output", output);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> inpatientPrescription(Map<String, String> params) {
|
||||
log.info("住院处方上传: params={}", params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("infcode", 0);
|
||||
Map<String, Object> output = new HashMap<>();
|
||||
output.put("recipe_no", "ZYCF" + System.currentTimeMillis());
|
||||
output.put("upload_time", new Date().toString());
|
||||
output.put("total_amount", "2580.50");
|
||||
output.put("insurance_pay", "2322.45");
|
||||
output.put("self_pay", "258.05");
|
||||
output.put("status", "成功");
|
||||
result.put("output", output);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Map<String, Object> inpatientSettle(Map<String, String> params) {
|
||||
log.info("住院结算: params={}", params);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("infcode", 0);
|
||||
Map<String, Object> output = new HashMap<>();
|
||||
output.put("settle_no", "ZYJS" + System.currentTimeMillis());
|
||||
output.put("total_amount", "15680.50");
|
||||
output.put("insurance_pay", "14112.45");
|
||||
output.put("self_pay", "1568.05");
|
||||
output.put("account_pay", "1200.00");
|
||||
output.put("cash_pay", "368.05");
|
||||
output.put("settle_time", new Date().toString());
|
||||
output.put("status", "成功");
|
||||
result.put("output", output);
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildPsnInfoOutput(YbPsnInfo psnInfo) {
|
||||
Map<String, Object> output = new HashMap<>();
|
||||
output.put("psn_no", psnInfo.getPsnNo());
|
||||
output.put("psn_name", psnInfo.getPsnName());
|
||||
output.put("sex_code", psnInfo.getSexCode());
|
||||
output.put("sex_name", psnInfo.getSexName());
|
||||
output.put("birth_date", psnInfo.getBirthDate());
|
||||
output.put("id_card", psnInfo.getIdCard());
|
||||
output.put("insur_type", psnInfo.getInsurType());
|
||||
output.put("insur_area", psnInfo.getInsurArea());
|
||||
output.put("card_no", psnInfo.getCardNo());
|
||||
output.put("balance", psnInfo.getBalance().toString());
|
||||
output.put("status", psnInfo.getStatus());
|
||||
return output;
|
||||
}
|
||||
|
||||
public YbPsnInfo addPsnInfo(YbPsnInfo psnInfo) {
|
||||
psnInfo.setCreateTime(new Date());
|
||||
psnInfo.setUpdateTime(new Date());
|
||||
psnInfoMapper.insert(psnInfo);
|
||||
return psnInfo;
|
||||
}
|
||||
|
||||
public List<YbPsnInfo> listPsnInfo() {
|
||||
return psnInfoMapper.selectList(new LambdaQueryWrapper<>());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user