feat(yb): 添加医保模拟服务器和测试脚本
- 创建YbMockController模拟医保接口 - 支持门诊/住院全流程测试(1101/2201/2203/2207/3201/3203/3207) - 添加测试脚本test-yb-mock.sh - 添加使用说明文档
This commit is contained in:
@@ -0,0 +1,174 @@
|
||||
package com.healthlink.his.yb.mock;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 医保模拟服务器 - 用于本地测试
|
||||
*
|
||||
* 模拟广西医保电子凭证接口:
|
||||
* - 1101: 获取参保人信息
|
||||
* - 2201: 门诊登记
|
||||
* - 2203: 门诊处方上传
|
||||
* - 2207: 门诊结算
|
||||
* - 3201: 住院登记
|
||||
* - 3203: 住院处方上传
|
||||
* - 3207: 住院结算
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/yb/mock")
|
||||
@Slf4j
|
||||
public class YbMockController {
|
||||
|
||||
/**
|
||||
* 模拟医保接口入口
|
||||
*/
|
||||
@PostMapping("/{apiCode}")
|
||||
public R<?> handleApi(@PathVariable String apiCode, @RequestBody String request) {
|
||||
log.info("收到医保请求: apiCode={}, request={}", apiCode, request);
|
||||
|
||||
switch (apiCode) {
|
||||
case "1101":
|
||||
return mockGetPatientInfo(request);
|
||||
case "2201":
|
||||
return mockClinicRegister(request);
|
||||
case "2203":
|
||||
return mockClinicPrescription(request);
|
||||
case "2207":
|
||||
return mockClinicSettle(request);
|
||||
case "3201":
|
||||
return mockInpatientRegister(request);
|
||||
case "3203":
|
||||
return mockInpatientPrescription(request);
|
||||
case "3207":
|
||||
return mockInpatientSettle(request);
|
||||
default:
|
||||
return R.ok(mockDefaultResponse(apiCode));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1101: 获取参保人信息
|
||||
*/
|
||||
private R<?> mockGetPatientInfo(String request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("psn_no", "P1234567890");
|
||||
result.put("psn_name", "张三");
|
||||
result.put("sex_code", "1");
|
||||
result.put("sex_name", "男");
|
||||
result.put("birth_date", "1980-01-15");
|
||||
result.put("id_card", "450123198001151234");
|
||||
result.put("insur_type", "职工基本医疗保险");
|
||||
result.put("insur_area", "南宁市");
|
||||
result.put("card_no", "C2024000123456");
|
||||
result.put("balance", "12580.50");
|
||||
result.put("status", "正常");
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2201: 门诊登记
|
||||
*/
|
||||
private R<?> mockClinicRegister(String request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("encounter_no", "MZ20260623001");
|
||||
result.put("register_time", new Date().toString());
|
||||
result.put("status", "成功");
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2203: 门诊处方上传
|
||||
*/
|
||||
private R<?> mockClinicPrescription(String request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("recipe_no", "CF20260623001");
|
||||
result.put("upload_time", new Date().toString());
|
||||
result.put("total_amount", "156.80");
|
||||
result.put("self_pay", "23.52");
|
||||
result.put("insurance_pay", "133.28");
|
||||
result.put("status", "成功");
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2207: 门诊结算
|
||||
*/
|
||||
private R<?> mockClinicSettle(String request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("settle_no", "JZ20260623001");
|
||||
result.put("total_amount", "156.80");
|
||||
result.put("insurance_pay", "133.28");
|
||||
result.put("self_pay", "23.52");
|
||||
result.put("account_pay", "20.00");
|
||||
result.put("cash_pay", "3.52");
|
||||
result.put("settle_time", new Date().toString());
|
||||
result.put("status", "成功");
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3201: 住院登记
|
||||
*/
|
||||
private R<?> mockInpatientRegister(String request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("admission_no", "ZY20260623001");
|
||||
result.put("admission_time", new Date().toString());
|
||||
result.put("bed_no", "3-201-1");
|
||||
result.put("status", "成功");
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3203: 住院处方上传
|
||||
*/
|
||||
private R<?> mockInpatientPrescription(String request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("recipe_no", "ZYCF20260623001");
|
||||
result.put("upload_time", new Date().toString());
|
||||
result.put("total_amount", "2580.50");
|
||||
result.put("insurance_pay", "2322.45");
|
||||
result.put("self_pay", "258.05");
|
||||
result.put("status", "成功");
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3207: 住院结算
|
||||
*/
|
||||
private R<?> mockInpatientSettle(String request) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("settle_no", "ZYJS20260623001");
|
||||
result.put("total_amount", "15680.50");
|
||||
result.put("insurance_pay", "14112.45");
|
||||
result.put("self_pay", "1568.05");
|
||||
result.put("account_pay", "1200.00");
|
||||
result.put("cash_pay", "368.05");
|
||||
result.put("settle_time", new Date().toString());
|
||||
result.put("status", "成功");
|
||||
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认响应
|
||||
*/
|
||||
private Map<String, Object> mockDefaultResponse(String apiCode) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("api_code", apiCode);
|
||||
result.put("status", "成功");
|
||||
result.put("message", "模拟响应");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
58
scripts/test-yb-mock.sh
Normal file
58
scripts/test-yb-mock.sh
Normal file
@@ -0,0 +1,58 @@
|
||||
# test-yb-mock.sh
|
||||
# 医保模拟接口测试脚本
|
||||
|
||||
BASE_URL="http://localhost:18080/healthlink-his/yb/mock"
|
||||
|
||||
echo "=== 医保模拟接口测试 ==="
|
||||
echo ""
|
||||
|
||||
# 1. 测试获取参保人信息 (1101)
|
||||
echo "1. 测试获取参保人信息 (1101)..."
|
||||
curl -s -X POST "${BASE_URL}/1101" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"psn_no":"P1234567890"}' | python3 -m json.tool
|
||||
echo ""
|
||||
|
||||
# 2. 测试门诊登记 (2201)
|
||||
echo "2. 测试门诊登记 (2201)..."
|
||||
curl -s -X POST "${BASE_URL}/2201" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"psn_no":"P1234567890","org_code":"H22010402403"}' | python3 -m json.tool
|
||||
echo ""
|
||||
|
||||
# 3. 测试门诊处方上传 (2203)
|
||||
echo "3. 测试门诊处方上传 (2203)..."
|
||||
curl -s -X POST "${BASE_URL}/2203" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"psn_no":"P1234567890","encounter_no":"MZ20260623001","recipe_list":[]}' | python3 -m json.tool
|
||||
echo ""
|
||||
|
||||
# 4. 测试门诊结算 (2207)
|
||||
echo "4. 测试门诊结算 (2207)..."
|
||||
curl -s -X POST "${BASE_URL}/2207" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"psn_no":"P1234567890","encounter_no":"MZ20260623001","total_amount":156.80}' | python3 -m json.tool
|
||||
echo ""
|
||||
|
||||
# 5. 测试住院登记 (3201)
|
||||
echo "5. 测试住院登记 (3201)..."
|
||||
curl -s -X POST "${BASE_URL}/3201" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"psn_no":"P1234567890","org_code":"H22010402403"}' | python3 -m json.tool
|
||||
echo ""
|
||||
|
||||
# 6. 测试住院处方上传 (3203)
|
||||
echo "6. 测试住院处方上传 (3203)..."
|
||||
curl -s -X POST "${BASE_URL}/3203" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"psn_no":"P1234567890","encounter_no":"ZY20260623001","recipe_list":[]}' | python3 -m json.tool
|
||||
echo ""
|
||||
|
||||
# 7. 测试住院结算 (3207)
|
||||
echo "7. 测试住院结算 (3207)..."
|
||||
curl -s -X POST "${BASE_URL}/3207" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"psn_no":"P1234567890","encounter_no":"ZY20260623001","total_amount":15680.50}' | python3 -m json.tool
|
||||
echo ""
|
||||
|
||||
echo "=== 测试完成 ==="
|
||||
Reference in New Issue
Block a user