江苏工伤联网接口参数说明.md 53 KB

江苏工伤联网接口参数说明


1. 交易代码与业务名称一览

交易英文名 交易代码 业务含义
SignIn 9001 签到
SignOut 9002 签退
ReadCard 1101 读卡
RegisterPatient 2201 门诊/住院登记
CancelRegister 2202 登记撤销
ModifyRegister 2203 登记信息修改
UploadPrescription 2204 处方明细上报
CancelPrescription 2205 处方明细撤销
PreSettle 2206 费用预结算
Settle 2207 费用结算
CancelSettle 2208 费用结算撤销
ReverseTransaction 2209 冲正交易
UploadReferral 2301 转诊转院申请上传
QueryReferral 2302 转诊转院申请查询
CancelReferral 2303 转诊转院申请撤销
TotalAccount 1320 总额对账
DetailAccount 1321 明细对账
BatchDownload 1301 批量数据下载
QueryFeeDetail 9103 费用明细详细信息下载
QueryPrescriptionDetail 9104 处方明细下载
QueryRecentVisit 9105 参保人近期就诊信息查询

2. 通用接口请求参数结构

所有交易通过 /api/entry/workinjury POST 方式调用,通用请求体结构如下:

{
  "action": "transaction",           // 固定为"transaction"
  "transactionName": "RegisterPatient", // 交易英文名或交易代码
  "businessParams": { ... },         // 业务参数对象(每个交易不同)
  "identifyMode": "1",               // 识别方式:1-实体社保卡,2-电子凭证(可选,默认1)
  "qrCodeInfo": "",                  // 电子社保卡二维码(识别方式为2时必填)
  "operatorId": "",                  // 经办人编号(可选)
  "operatorName": ""                 // 经办人姓名(可选)
}
  • action:必须为 "transaction",由前端指定。
  • transactionName:交易英文名(如 "RegisterPatient")或4位数字代码(如 "2201")。
  • businessParams每个交易的核心参数,结构见下文。
  • 其余为通用可选参数。

3. 各交易业务参数(businessParams)明细

3.1 SignIn(签到)

  • 请求参数:无业务参数,businessParams 可省略或为空对象 {}
  • 示例

    {
    "action": "transaction",
    "transactionName": "SignIn"
    }
    

    3.2 SignOut(签退)

    • 请求参数:无业务参数,businessParams 可省略或为空对象 {}
    • 示例json { "action": "transaction", "transactionName": "SignOut" }

3.3 ReadCard(读卡)

  • 请求参数:无业务参数,businessParams 可省略或为空对象 {}
  • 示例

    {
    "action": "transaction",
    "transactionName": "ReadCard"
    }
    

    3.4 RegisterPatient(门诊/住院登记)

    • 请求参数(示例,具体字段以业务文档为准): json { "action": "transaction", "transactionName": "RegisterPatient", "businessParams": { "patient_id": "xxx", // 患者ID "visit_type": "1", // 就诊类型(1-门诊,2-住院) "dept_code": "001", // 科室编码 "dept_name": "内科", // 科室名称 "doctor_code": "DOC001", // 医生编码 "doctor_name": "张医生" // 医生姓名 // ... 其他登记所需字段 } }

3.5 UploadPrescription(处方明细上报)

  • 请求参数(支持批量):

    {
    "action": "transaction",
    "transactionName": "UploadPrescription",
    "businessParams": {
      "patient_id": "xxx",
      "visit_no": "yyy",
      "batch_no": "1",
      "prescriptions": [
        {
          "item_code": "A001",
          "item_name": "药品A",
          "amount": 1,
          "price": 10.0
          // ... 处方明细字段
        }
        // ... 多条
      ]
    }
    }
    

    3.6 Settle(费用结算)

    • 请求参数(示例): json { "action": "transaction", "transactionName": "Settle", "businessParams": { "visit_no": "yyy", "pre_settle_id": "zzz" // ... 其他结算所需字段 } }

其余交易(如 CancelRegister、ModifyRegister、PreSettle、CancelSettle、ReverseTransaction、UploadReferral、QueryReferral、CancelReferral、TotalAccount、DetailAccount、BatchDownload、QueryFeeDetail、QueryPrescriptionDetail、QueryRecentVisit)均以类似方式传递业务参数,字段详见业务文档和接口实现。


4. 接口返回参数结构

4.1 通用返回字段

所有接口返回均为 JSON 对象,通用字段如下:

字段名 类型 说明
success bool 是否成功(true/false)
code int 状态码(200为成功,其他为错误)
message string 结果描述
device string 设备/接口标识(如“江苏工伤联网接口”)
data object 业务数据(结构随交易不同)
transactionCode string 交易代码(如"2201")
request_parameters object 原始请求参数(完整回传)
transformed_parameters object 标准化后传递给 DLL 的参数(调试用)
rawOutput string DLL原始返回JSON(调试用)
debug_xxx ... 各类调试信息(如 debug_step、debug_error 等)
  • request_parameters:始终包含前端原始请求体(便于追溯)。
  • transformed_parameters:包含标准化后传递给 DLL 的参数(便于调试和问题定位)。
  • data:为业务返回数据,结构随交易不同(如登记返回登记号、结算返回结算单号等)。
  • rawOutput:DLL返回的原始JSON字符串,便于底层问题排查。
  • debug_xxx:调试辅助字段,便于开发和定位问题。

5. 典型交易参数与返回结构明细

5.1 SignIn(签到)

  • 请求参数 businessParams:无(可省略或 {}
  • 返回 data 字段结构(参考 DLL 返回):

    {
    "sign_no": "签到流水号",
    "sign_time": "签到时间(yyyyMMddHHmmss)"
    }
    

    5.2 SignOut(签退)

    • 请求参数 businessParams:无
    • 返回 data 字段结构json { "sign_no": "签退流水号", "sign_time": "签退时间(yyyyMMddHHmmss)" }

5.3 ReadCard(读卡)

  • 请求参数 businessParams:无
  • 返回 data 字段结构(示例):

    {
    "card_no": "社保卡号",
    "psn_no": "人员编号",
    "psn_name": "姓名",
    "gend": "性别",
    "certno": "身份证号"
    }
    

    5.4 RegisterPatient(门诊/住院登记)

    • 请求参数 businessParams(常见字段,具体以业务文档为准): | 字段名 | 类型 | 说明 | |----------------|--------|--------------| | patient_id | string | 患者ID | | visit_type | string | 就诊类型 | | dept_code | string | 科室编码 | | dept_name | string | 科室名称 | | doctor_code | string | 医生编码 | | doctor_name | string | 医生姓名 | | ... | ... | 其他登记字段 |
    • 返回 data 字段结构(示例): json { "visit_no": "就诊流水号", "register_time": "登记时间" }

5.5 UploadPrescription(处方明细上报)

  • 请求参数 businessParams(支持批量): | 字段名 | 类型 | 说明 | |----------------|----------|--------------| | patient_id | string | 患者ID | | visit_no | string | 就诊流水号 | | batch_no | string | 批次号 | | prescriptions | array | 处方明细数组 |

prescriptions 内部结构(示例): | 字段名 | 类型 | 说明 | |------------|--------|----------| | item_code | string | 项目编码 | | item_name | string | 项目名称 | | amount | number | 数量 | | price | number | 单价 | | ... | ... | 其他字段 |

  • 返回 data 字段结构(示例):

    {
    "upload_result": "success",
    "uploaded_count": 10,
    "batch_no": "1"
    }
    

    5.6 PreSettle(费用预结算)

    • 请求参数 businessParams(示例): | 字段名 | 类型 | 说明 | |----------------|--------|--------------| | visit_no | string | 就诊流水号 | | fee_details | array | 费用明细数组 |
    • 返回 data 字段结构(示例): json { "pre_settle_id": "预结算ID", "total_amount": 100.0 }

5.7 Settle(费用结算)

  • 请求参数 businessParams(示例): | 字段名 | 类型 | 说明 | |----------------|--------|--------------| | visit_no | string | 就诊流水号 | | pre_settle_id | string | 预结算ID |
  • 返回 data 字段结构(示例):

    {
    "settle_id": "结算单号",
    "total_amount": 100.0,
    "fund_pay": 80.0,
    "cash_pay": 20.0
    }
    

    5.8 CancelRegister(登记撤销)

    • 请求参数 businessParams(示例): | 字段名 | 类型 | 说明 | |----------------|--------|--------------| | visit_no | string | 就诊流水号 |
    • 返回 data 字段结构(示例): json { "cancel_result": "success" }

5.9 ReverseTransaction(冲正交易)

  • 请求参数 businessParams(示例): | 字段名 | 类型 | 说明 | |------------------------|--------|--------------| | original_msg_id | string | 原报文ID | | original_transaction_code | string | 原交易代码 | | original_transaction_time | string | 原交易时间 | | reverse_reason | string | 冲正原因 |
  • 返回 data 字段结构(示例):

    {
    "reverse_result": "success"
    }
    

    5.10 其他交易(如对账、下载、转院等)

    • 请求参数 businessParams:根据业务文档和 DLL 要求传递,通常为查询条件、时间范围、编号等。
    • 返回 data 字段结构:通常为明细列表、对账结果、下载数据等。

    6. 通用返回字段详细说明

    字段名 类型 说明
    success bool 是否成功(true/false)
    code int 状态码(200为成功,其他为错误)
    message string 结果描述
    device string 设备/接口标识(如“江苏工伤联网接口”)
    data object 业务数据(结构随交易不同)
    transactionCode string 交易代码(如"2201")
    request_parameters object 原始请求参数(完整回传)
    transformed_parameters object 标准化后传递给 DLL 的参数(调试用)
    rawOutput string DLL原始返回JSON(调试用)
    debug_xxx ... 各类调试信息(如 debug_step、debug_error 等)
    • request_parameters:前端传入的完整请求体,便于追溯。
    • transformed_parameters:后端标准化后传递给 DLL 的参数,便于调试。
    • rawOutput:DLL 返回的原始 JSON 字符串。
    • debug_xxx:调试辅助字段,便于开发和定位问题。

    7. 示例:完整请求与返回

    7.1 请求示例(登记)

    POST /api/entry/workinjury
    {
    "action": "transaction",
    "transactionName": "RegisterPatient",
    "businessParams": {
    "patient_id": "P123456",
    "visit_type": "1",
    "dept_code": "001",
    "dept_name": "内科",
    "doctor_code": "DOC001",
    "doctor_name": "张医生"
    }
    }
    

7.2 返回示例

{
  "success": true,
  "code": 200,
  "message": "交易成功",
  "device": "江苏工伤联网接口",
  "data": {
    "visit_no": "V20230722001",
    "register_time": "2023-07-22 10:00:00"
  },
  "transactionCode": "2201",
  "request_parameters": {
    "action": "transaction",
    "transactionName": "RegisterPatient",
    "businessParams": {
      "patient_id": "P123456",
      "visit_type": "1",
      "dept_code": "001",
      "dept_name": "内科",
      "doctor_code": "DOC001",
      "doctor_name": "张医生"
    }
  },
  "transformed_parameters": {
    "infno": "2201",
    "msgid": "SQ201348202307221000000001",
    "recer_sys_code": "JSYTH",
    "infver": "V2.1",
    "opter_type": "1",
    "opter": "001",
    "opter_name": "系统管理员",
    "inf_time": "20230722100000",
    "fixmedins_code": "SQ201348",
    "fixmedins_name": "沭阳铭和医院",
    "sign_no": "签到流水号",
    "idfi_mode": "1",
    "qrcode_info": "",
    "input": {
      "patient_id": "P123456",
      "visit_type": "1",
      "dept_code": "001",
      "dept_name": "内科",
      "doctor_code": "DOC001",
      "doctor_name": "张医生"
    }
  },
  "rawOutput": "{...DLL原始返回...}",
  "debug_step": "Si_Busi调用完成"
}

8. 结论与建议

  • 所有交易的请求参数均以 businessParams 传递,字段结构需参考业务文档和 DLL 要求。
  • 所有返回均包含原始请求、标准化参数、业务数据、调试信息,便于前后端联调和问题定位。
  • 如需详细字段定义,请结合工伤联网接口官方文档与本项目代码实现。

如需Word/Excel 版本特定交易的详细字段说明,请补充需求!

如需下载版 Markdown 文档,可将本内容保存为 江苏工伤联网接口参数说明.md


下面是完整的 Magic API 模拟接口代码(可直接复制到 Magic API 脚本编辑器使用),用于模拟江苏工伤联网接口的所有主要交易,返回结构与《江苏工伤联网接口参数说明.md》一致:

import cn.hutool.core.util.IdUtil;

// Magic API模拟接口:江苏工伤联网接口模拟
// 适配SQL Server 2008
// 用于前端联调和接口测试
//
// =====================
// 交易请求参数详解:
//
// 通用请求结构:
// {
//   "action": "transaction", // 固定为"transaction"
//   "transactionName": "交易英文名或代码", // 如"SignIn"、"RegisterPatient"、"2201"等
//   "businessParams": { ... }, // 业务参数对象(每个交易不同,详见下方)
//   "identifyMode": "1", // 识别方式:1-实体社保卡,2-电子凭证(可选,默认1)
//   "qrCodeInfo": "", // 电子社保卡二维码(识别方式为2时必填)
//   "operatorId": "", // 经办人编号(可选)
//   "operatorName": "" // 经办人姓名(可选)
// }
//
// 9001 签到(SignIn)
//   - businessParams: {} // 无需业务参数,可省略或传空对象
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "SignIn"
//     }
//
// 1101 读卡(ReadCard)
//   - businessParams: {} // 无需业务参数,可省略或传空对象
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "ReadCard"
//     }
//
// 2201 门诊/住院登记(RegisterPatient)
//   - businessParams: {
//       "patient_id": "string", // 患者ID(必填)
//       "visit_type": "1", // 就诊类型(1-门诊,2-住院)(必填)
//       "dept_code": "001", // 科室编码(必填)
//       "dept_name": "内科", // 科室名称(必填)
//       "doctor_code": "DOC001", // 医生编码(必填)
//       "doctor_name": "张医生" // 医生姓名(必填)
//       ... // 其他登记所需字段,详见官方文档
//     }
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "RegisterPatient",
//       "businessParams": {
//         "patient_id": "P123456",
//         "visit_type": "1",
//         "dept_code": "001",
//         "dept_name": "内科",
//         "doctor_code": "DOC001",
//         "doctor_name": "张医生"
//       }
//     }
//
// 2204 处方明细上报(UploadPrescription)
//   - businessParams: {
//       "patient_id": "string", // 患者ID(必填)
//       "visit_no": "string", // 就诊流水号(必填)
//       "batch_no": "1", // 批次号(必填,建议从1递增)
//       "prescriptions": [ // 处方明细数组(必填,最多50条)
//         {
//           "item_code": "A001", // 项目编码(必填)
//           "item_name": "药品A", // 项目名称(必填)
//           "amount": 1, // 数量(必填)
//           "price": 10.0 // 单价(必填)
//           ... // 其他明细字段,详见官方文档
//         }
//         // ...多条
//       ]
//     }
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "UploadPrescription",
//       "businessParams": {
//         "patient_id": "P123456",
//         "visit_no": "V20230722001",
//         "batch_no": "1",
//         "prescriptions": [
//           { "item_code": "A001", "item_name": "药品A", "amount": 1, "price": 10.0 }
//         ]
//       }
//     }
//
// 2206/2207 费用预结算/结算(PreSettle/Settle)
//   - businessParams: {
//       "visit_no": "string", // 就诊流水号(必填)
//       "pre_settle_id": "string", // 预结算ID(结算时必填)
//       ... // 其他结算所需字段,详见官方文档
//     }
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "Settle",
//       "businessParams": {
//         "visit_no": "V20230722001",
//         "pre_settle_id": "PRE20230722001"
//       }
//     }
//
// 1320/1321 对账类(TotalAccount/DetailAccount)
//   - businessParams: {
//       "stmt_begindate": "20240701", // 对账开始时间(必填,格式yyyyMMdd)
//       "stmt_enddate": "20240722", // 对账结束时间(必填,格式yyyyMMdd)
//       "sign_no": "string", // 签到流水号(可选)
//       ... // 其他对账所需字段,详见官方文档
//     }
//
// 2209 冲正交易(ReverseTransaction)
//   - businessParams: {
//       "infno": "2201", // 冲正交易编号(必填,2201/2207/2208)
//       "msgid": "string" // 发送方报文ID(必填)
//     }
//
// 9103/9104/9105 查询/下载类
//   - businessParams: {
//       "ipt_otp_no": "string", // 门诊/住院流水号(必填)
//       "mdtrt_id": "string", // 单据号(必填,部分接口)
//       "pageNumber": 1 // 页码(可选,默认1)
//       ... // 其他查询条件,详见官方文档
//     }
//
// 81xx 体检类、23xx 转诊转院类等
//   - businessParams: 详见官方文档,按接口要求传递
//
// 其他上传/登记/撤销类交易
//   - businessParams: 按官方文档必填字段传递
//
// =====================
//
// 交易返回字段详解:
//
// 9001 签到(SignIn)
//   output: { sign_no, sign_time }
//   - sign_no: 签到流水号(中心生成,唯一)
//   - sign_time: 签到时间(yyyyMMddHHmmss)
//
// 1101 读卡(ReadCard)
//   output: { psn_no, emp_no, emp_name, certno, psn_name, gend, age, psn_type, insu_admdvs, inhosp_stas, trt_chk_rslt, exam_ccls, certificate_type, birthday }
//   - exam_ccls: 工伤诊断结论,格式为^工伤医疗费资格审核信息ID|受伤部位信息描述|就诊类型^
//   - gend/psn_type/certificate_type等详见二级代码表
//
// 2201 门诊/住院登记(RegisterPatient)
//   output: 无(登记成功output为空,infcode=0)
//
// 2204 处方明细上报(UploadPrescription)
//   output: 数组,每条明细返回 { rxno, feedetl_sn, fee_ocur_time, med_list_codg, umamt, ownpay_amt, alwpay_amt, pric_uplmt_amt, chrgitm_lv, memo }
//
// 2206/2207 费用预结算/结算(PreSettle/Settle)
//   output: { ipt_otp_no, mdtrt_id, medfee_sumamt, hifp_pay, psn_cash_pay, med_list_codg, umamt, drug_fee, dati_fee, ms_fee }
//
// 1320 总额对账(TotalAccount)
//   output: { medfee_sumamt, hifp_pay, psn_cash_pay }
//
// 1321 明细对账(DetailAccount)
//   output: { ipt_otp_no, medrcdno, medfee_sumamt, hifp_pay, psn_cash_pay }
//
// 2209 冲正交易(ReverseTransaction)
//   output: { rec_state, medfee_sumamt }
//
// 9103 费用明细详细信息下载(QueryFeeDetail)
//   output: 数组,每行 { ipt_otp_no, medrcdno, medfee_sumamt, hifp_pay, psn_cash_pay, msgid, med_type, psn_no, psn_name, setl_time, opter, pageCount }
//
// 9104 处方明细下载(QueryPrescriptionDetail)
//   output: 数组,每行 { ipt_otp_no, medrcdno, rxno, feedetl_sn, fee_ocur_time, med_list_codg, pric, cnt, umamt, ownpay_amt, alwpay_amt, pric_uplmt_amt, chrgitm_lv, memo, list_type, pageCount }
//
// 9105 参保人近期就诊信息查询(QueryRecentVisit)
//   output: 数组,每行 { fixmedins_code, fixmedins_name, adm_time, dscg_time, dscg_trt_rslt, diag_code, med_type, medfee_sumamt, setl_time }
//
// 81xx 体检类查询(如8101、8103、8106、8107、8109)
//   output: 数组,详见官方文档表格,每行含pageCount
//
// 23xx 转诊转院类(如2302)
//   output: 数组,每行 { referral_id, actualStartTime, actualEndTime, outArea, outHospitalName, applyReason, transportation, stateCode, applyTime, qualification_id }
//
// 其他上传/登记/撤销类交易 output为空,仅需判断infcode=0
//
// 常用二级代码表:
//   性别(gend):1男 2女 9未说明
//   工伤人员类别(psn_type):01新工伤 02老工伤 ...
//   证件类型(certificate_type):01居民身份证 04港澳居民来往内地通行证 ...
//   医疗类别(med_type):11门诊肢体残 12门诊职业病 ...
//   在院状态(inhosp_stas):0未在院 1工伤在院 2医疗在院
//   审核状态(audit_status):0未审核 1已审核
//   体检类别(examination_type):1社服体检
//   报告领取地(receivingaddress):1医院 2社区
//   出院原因(dscg_trt_rslt):01治愈 02死亡 03转院 04其它 05好转
//   收费项目等级(chrgitm_lv):1甲类 2乙类 3丙类
//   是否最小计量单位(min_unit):0否 1是
//   全额自费标志(allSelfFlag):0否 1是
//   三大目录类别(list_type):1药品 2诊疗项目 3材料
//
// 错误码说明:infcode=0成功,-1失败,err_msg返回错误信息
// 分页说明:查询/下载类接口output为数组,每行含pageCount,入参pageNumber控制页码
//
// 更多详见本文件参数说明章节和官方文档

if (!body) {
    exit -1, "参数body不能为空";
}
var dataParams = body;

// 解析通用参数
var action           = dataParams.action           ? dataParams.action           : '';
var transactionName  = dataParams.transactionName  ? dataParams.transactionName  : '';
var businessParams   = dataParams.businessParams   ? dataParams.businessParams   : {};
var identifyMode     = dataParams.identifyMode     ? dataParams.identifyMode     : '1';
var qrCodeInfo       = dataParams.qrCodeInfo       ? dataParams.qrCodeInfo       : '';
var operatorId       = dataParams.operatorId       ? dataParams.operatorId       : '';
var operatorName     = dataParams.operatorName     ? dataParams.operatorName     : '';

// 生成UUID
var simpleUUID = IdUtil.simpleUUID();

// 交易代码映射
var transactionMap = {
    "SignIn": "9001",
    "SignOut": "9002",
    "ReadCard": "1101",
    "RegisterPatient": "2201",
    "CancelRegister": "2202",
    "ModifyRegister": "2203",
    "UploadPrescription": "2204",
    "CancelPrescription": "2205",
    "PreSettle": "2206",
    "Settle": "2207",
    "CancelSettle": "2208",
    "ReverseTransaction": "2209",
    "UploadReferral": "2301",
    "QueryReferral": "2302",
    "CancelReferral": "2303",
    "TotalAccount": "1320",
    "DetailAccount": "1321",
    "BatchDownload": "1301",
    "QueryFeeDetail": "9103",
    "QueryPrescriptionDetail": "9104",
    "QueryRecentVisit": "9105"
};

// 交易代码
var transactionCode = transactionMap[transactionName] ? transactionMap[transactionName] : transactionName;

// =====================
// 自动签到逻辑(全局sign_no复用):
// 对所有业务类交易(非签到/签退),如果businessParams未带sign_no或为空,先自动执行一次签到,拿到sign_no后补充到businessParams。
// sign_no为全局唯一,首次自动签到后全局复用,直到签退或重置。
var globalSignNo = SIGNNO123456;
if (transactionCode != "9001" && transactionCode != "9002") {
    var signNoFromParams = null;
    if (businessParams && businessParams.sign_no !== undefined) {
        signNoFromParams = businessParams.sign_no;
    }
    if (!signNoFromParams) {
        if (!globalSignNo) {
            globalSignNo = "SIGNNO" + simpleUUID.substring(0, 8);
        }
        if (!businessParams) {
            businessParams = {}
        };
        businessParams.sign_no = globalSignNo;
        // 可选:可在result中增加debug_auto_signin = true
    }
}
// =====================

// 通用返回结构
var result = {
    success: true,
    code: 200,
    message: "交易成功",
    device: "江苏工伤联网接口(模拟)",
    transactionCode: transactionCode,
    request_parameters: dataParams,
    transformed_parameters: {
        infno: transactionCode,
        msgid: "SQ201348202307221000000001",
        recer_sys_code: "JSYTH",
        infver: "V2.1",
        opter_type: "1",
        opter: operatorId ? operatorId : "001",
        opter_name: operatorName ? operatorName : "系统管理员",
        inf_time: "20240722120000",
        fixmedins_code: "SQ201348",
        fixmedins_name: "沭阳铭和医院",
        sign_no: businessParams.sign_no || "SIGNNO123456",
        idfi_mode: identifyMode,
        qrcode_info: qrCodeInfo,
        input: businessParams
    },
    rawOutput: "",
    debug_step: "模拟接口返回"
};

// 针对不同交易,返回不同data结构
if (transactionCode == "9001") {
    result.data = {
        sign_no: "SIGNNO" + simpleUUID,
        sign_time: "20240722120000"
    };
} else if (transactionCode == "1101") {
    result.data = {
        psn_no: "PSN" + simpleUUID.substring(0,6),
        emp_no: "EMP" + simpleUUID.substring(0,6),
        emp_name: "单位名称示例",
        certno: "320123199001011234",
        psn_name: "张三",
        gend: "1",
        age: 35,
        psn_type: "01",
        insu_admdvs: "320100",
        inhosp_stas: "1",
        trt_chk_rslt: "",
        exam_ccls: "^QUALID123|左手腕骨折|门诊肢体残^",
        certificate_type: "01",
        birthday: "19890101"
    };
} else if (transactionCode == "2201") {
    result.data = null;
} else if (transactionCode == "2204") {
    result.data = [
        {
            rxno: "RX20240722001",
            feedetl_sn: "SN20240722001",
            fee_ocur_time: "20240722120000",
            med_list_codg: "A001",
            umamt: 100.0,
            ownpay_amt: 0.0,
            alwpay_amt: 0.0,
            pric_uplmt_amt: 100.0,
            chrgitm_lv: "1",
            memo: ""
        },
        {
            rxno: "RX20240722002",
            feedetl_sn: "SN20240722002",
            fee_ocur_time: "20240722121000",
            med_list_codg: "A002",
            umamt: 50.0,
            ownpay_amt: 0.0,
            alwpay_amt: 0.0,
            pric_uplmt_amt: 50.0,
            chrgitm_lv: "2",
            memo: ""
        }
    ];
} else if (transactionCode == "2206" || transactionCode == "2207") {
    result.data = {
        ipt_otp_no: "V" + simpleUUID.substring(0,10),
        mdtrt_id: "MDT" + simpleUUID.substring(0,8),
        medfee_sumamt: 1000.00,
        hifp_pay: 800.00,
        psn_cash_pay: 200.00,
        med_list_codg: "A001",
        umamt: 1000.00,
        drug_fee: 300.00,
        dati_fee: 400.00,
        ms_fee: 300.00
    };
} else if (transactionCode == "1320") {
    result.data = {
        medfee_sumamt: 10000.00,
        hifp_pay: 8000.00,
        psn_cash_pay: 2000.00
    };
} else if (transactionCode == "1321") {
    result.data = {
        ipt_otp_no: "V" + simpleUUID.substring(0,10),
        medrcdno: "M" + simpleUUID.substring(0,8),
        medfee_sumamt: 1000.00,
        hifp_pay: 800.00,
        psn_cash_pay: 200.00
    };
} else if (transactionCode == "2209") {
    result.data = {
        rec_state: "1",
        medfee_sumamt: 1000.00
    };
} else if (transactionCode == "9103") {
    result.data = [
        {
            ipt_otp_no: "V" + simpleUUID.substring(0,10),
            medrcdno: "M" + simpleUUID.substring(0,8),
            medfee_sumamt: 1000.00,
            hifp_pay: 800.00,
            psn_cash_pay: 200.00,
            msgid: "SQ201348202307221000000001",
            med_type: "11",
            psn_no: "PSN" + simpleUUID.substring(0,6),
            psn_name: "张三",
            setl_time: "20240722120000",
            opter: "001",
            pageCount: 1
        }
    ];
} else if (transactionCode == "9104") {
    result.data = [
        {
            ipt_otp_no: "V" + simpleUUID.substring(0,10),
            medrcdno: "M" + simpleUUID.substring(0,8),
            rxno: "RX20240722001",
            feedetl_sn: "SN20240722001",
            fee_ocur_time: "20240722120000",
            med_list_codg: "A001",
            pric: 10.0,
            cnt: 2,
            umamt: 20.0,
            ownpay_amt: 0.0,
            alwpay_amt: 0.0,
            pric_uplmt_amt: 20.0,
            chrgitm_lv: "1",
            memo: "",
            list_type: "1",
            pageCount: 1
        }
    ];
} else if (transactionCode == "9105") {
    result.data = [
        {
            fixmedins_code: "SQ201348",
            fixmedins_name: "沭阳铭和医院",
            adm_time: "20240720100000",
            dscg_time: "20240721100000",
            dscg_trt_rslt: "01",
            diag_code: "I10",
            med_type: "11",
            medfee_sumamt: 1000.00,
            setl_time: "20240722120000"
        }
    ];
} else if (transactionCode == "8101") {
    result.data = [
        {
            order_date: "20240725",
            available_num: 100,
            reserved_num: 80,
            remaining_num: 20,
            physical_num: 75,
            pageCount: 1
        }
    ];
} else if (transactionCode == "8103") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            order_date: "20240725",
            order_id: 10001,
            psn_name: "张三",
            certno: "320123199001011234",
            gend: "1",
            age: 35,
            area: "320100",
            street: "XX街道",
            community: "XX社区",
            examination_type: "1",
            tel: "13800000000",
            receivingaddress: "1",
            nophyreason: "",
            pageCount: 1
        }
    ];
} else if (transactionCode == "8106") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            psn_name: "张三",
            order_id: 10001,
            physical_date: "20240725",
            completion_date: "20240726",
            settlement_date: "20240727",
            exam_date: "20240728",
            audit_status: "1",
            remarks: "无异常",
            pageCount: 1
        }
    ];
} else if (transactionCode == "8107") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            order_id: 10001,
            completion_date: "20240726",
            major_items: "A01",
            small_items: "B01",
            results: "正常",
            diagnosis: "无异常",
            normalrange: "参考值",
            pageCount: 1
        }
    ];
} else if (transactionCode == "8109") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            psn_name: "张三",
            order_id: 10001,
            physical_date: "20240725",
            remarks: "补刷卡登记",
            pageCount: 1
        }
    ];
} else if (transactionCode == "2302") {
    result.data = [
        {
            referral_id: "REF" + simpleUUID.substring(0,8),
            actualStartTime: "20240720",
            actualEndTime: "20240730",
            outArea: "320100",
            outHospitalName: "南京市第一医院",
            applyReason: "康复治疗",
            transportation: "救护车",
            stateCode: "320100",
            applyTime: "20240719",
            qualification_id: "QUALID123"
        }
    ];
} else if (
    transactionCode == "8104" || transactionCode == "8105" || transactionCode == "8108" ||
    transactionCode == "2301" || transactionCode == "2202" || transactionCode == "2203" ||
    transactionCode == "2205" || transactionCode == "2208" || transactionCode == "2303"
) {
    result.data = null;
} else {
    result.data = {
        info: "模拟数据",
        transaction: transactionCode
    };
}
// 业务错误模拟(如缺少必填参数)
if (!transactionCode) {
    result.success = false;
    result.code = 1001;
    result.message = "不支持的交易类型";
    result.data = null;
}
// 返回模拟结果
return result;import cn.hutool.core.util.IdUtil;

// Magic API模拟接口:江苏工伤联网接口模拟
// 适配SQL Server 2008
// 用于前端联调和接口测试
//
// =====================
// 交易请求参数详解:
//
// 通用请求结构:
// {
//   "action": "transaction", // 固定为"transaction"
//   "transactionName": "交易英文名或代码", // 如"SignIn"、"RegisterPatient"、"2201"等
//   "businessParams": { ... }, // 业务参数对象(每个交易不同,详见下方)
//   "identifyMode": "1", // 识别方式:1-实体社保卡,2-电子凭证(可选,默认1)
//   "qrCodeInfo": "", // 电子社保卡二维码(识别方式为2时必填)
//   "operatorId": "", // 经办人编号(可选)
//   "operatorName": "" // 经办人姓名(可选)
// }
//
// 9001 签到(SignIn)
//   - businessParams: {} // 无需业务参数,可省略或传空对象
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "SignIn"
//     }
//
// 1101 读卡(ReadCard)
//   - businessParams: {} // 无需业务参数,可省略或传空对象
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "ReadCard"
//     }
//
// 2201 门诊/住院登记(RegisterPatient)
//   - businessParams: {
//       "patient_id": "string", // 患者ID(必填)
//       "visit_type": "1", // 就诊类型(1-门诊,2-住院)(必填)
//       "dept_code": "001", // 科室编码(必填)
//       "dept_name": "内科", // 科室名称(必填)
//       "doctor_code": "DOC001", // 医生编码(必填)
//       "doctor_name": "张医生" // 医生姓名(必填)
//       ... // 其他登记所需字段,详见官方文档
//     }
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "RegisterPatient",
//       "businessParams": {
//         "patient_id": "P123456",
//         "visit_type": "1",
//         "dept_code": "001",
//         "dept_name": "内科",
//         "doctor_code": "DOC001",
//         "doctor_name": "张医生"
//       }
//     }
//
// 2204 处方明细上报(UploadPrescription)
//   - businessParams: {
//       "patient_id": "string", // 患者ID(必填)
//       "visit_no": "string", // 就诊流水号(必填)
//       "batch_no": "1", // 批次号(必填,建议从1递增)
//       "prescriptions": [ // 处方明细数组(必填,最多50条)
//         {
//           "item_code": "A001", // 项目编码(必填)
//           "item_name": "药品A", // 项目名称(必填)
//           "amount": 1, // 数量(必填)
//           "price": 10.0 // 单价(必填)
//           ... // 其他明细字段,详见官方文档
//         }
//         // ...多条
//       ]
//     }
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "UploadPrescription",
//       "businessParams": {
//         "patient_id": "P123456",
//         "visit_no": "V20230722001",
//         "batch_no": "1",
//         "prescriptions": [
//           { "item_code": "A001", "item_name": "药品A", "amount": 1, "price": 10.0 }
//         ]
//       }
//     }
//
// 2206/2207 费用预结算/结算(PreSettle/Settle)
//   - businessParams: {
//       "visit_no": "string", // 就诊流水号(必填)
//       "pre_settle_id": "string", // 预结算ID(结算时必填)
//       ... // 其他结算所需字段,详见官方文档
//     }
//   - 示例:
//     {
//       "action": "transaction",
//       "transactionName": "Settle",
//       "businessParams": {
//         "visit_no": "V20230722001",
//         "pre_settle_id": "PRE20230722001"
//       }
//     }
//
// 1320/1321 对账类(TotalAccount/DetailAccount)
//   - businessParams: {
//       "stmt_begindate": "20240701", // 对账开始时间(必填,格式yyyyMMdd)
//       "stmt_enddate": "20240722", // 对账结束时间(必填,格式yyyyMMdd)
//       "sign_no": "string", // 签到流水号(可选)
//       ... // 其他对账所需字段,详见官方文档
//     }
//
// 2209 冲正交易(ReverseTransaction)
//   - businessParams: {
//       "infno": "2201", // 冲正交易编号(必填,2201/2207/2208)
//       "msgid": "string" // 发送方报文ID(必填)
//     }
//
// 9103/9104/9105 查询/下载类
//   - businessParams: {
//       "ipt_otp_no": "string", // 门诊/住院流水号(必填)
//       "mdtrt_id": "string", // 单据号(必填,部分接口)
//       "pageNumber": 1 // 页码(可选,默认1)
//       ... // 其他查询条件,详见官方文档
//     }
//
// 81xx 体检类、23xx 转诊转院类等
//   - businessParams: 详见官方文档,按接口要求传递
//
// 其他上传/登记/撤销类交易
//   - businessParams: 按官方文档必填字段传递
//
// =====================
//
// 交易返回字段详解:
//
// 9001 签到(SignIn)
//   output: { sign_no, sign_time }
//   - sign_no: 签到流水号(中心生成,唯一)
//   - sign_time: 签到时间(yyyyMMddHHmmss)
//
// 1101 读卡(ReadCard)
//   output: { psn_no, emp_no, emp_name, certno, psn_name, gend, age, psn_type, insu_admdvs, inhosp_stas, trt_chk_rslt, exam_ccls, certificate_type, birthday }
//   - exam_ccls: 工伤诊断结论,格式为^工伤医疗费资格审核信息ID|受伤部位信息描述|就诊类型^
//   - gend/psn_type/certificate_type等详见二级代码表
//
// 2201 门诊/住院登记(RegisterPatient)
//   output: 无(登记成功output为空,infcode=0)
//
// 2204 处方明细上报(UploadPrescription)
//   output: 数组,每条明细返回 { rxno, feedetl_sn, fee_ocur_time, med_list_codg, umamt, ownpay_amt, alwpay_amt, pric_uplmt_amt, chrgitm_lv, memo }
//
// 2206/2207 费用预结算/结算(PreSettle/Settle)
//   output: { ipt_otp_no, mdtrt_id, medfee_sumamt, hifp_pay, psn_cash_pay, med_list_codg, umamt, drug_fee, dati_fee, ms_fee }
//
// 1320 总额对账(TotalAccount)
//   output: { medfee_sumamt, hifp_pay, psn_cash_pay }
//
// 1321 明细对账(DetailAccount)
//   output: { ipt_otp_no, medrcdno, medfee_sumamt, hifp_pay, psn_cash_pay }
//
// 2209 冲正交易(ReverseTransaction)
//   output: { rec_state, medfee_sumamt }
//
// 9103 费用明细详细信息下载(QueryFeeDetail)
//   output: 数组,每行 { ipt_otp_no, medrcdno, medfee_sumamt, hifp_pay, psn_cash_pay, msgid, med_type, psn_no, psn_name, setl_time, opter, pageCount }
//
// 9104 处方明细下载(QueryPrescriptionDetail)
//   output: 数组,每行 { ipt_otp_no, medrcdno, rxno, feedetl_sn, fee_ocur_time, med_list_codg, pric, cnt, umamt, ownpay_amt, alwpay_amt, pric_uplmt_amt, chrgitm_lv, memo, list_type, pageCount }
//
// 9105 参保人近期就诊信息查询(QueryRecentVisit)
//   output: 数组,每行 { fixmedins_code, fixmedins_name, adm_time, dscg_time, dscg_trt_rslt, diag_code, med_type, medfee_sumamt, setl_time }
//
// 81xx 体检类查询(如8101、8103、8106、8107、8109)
//   output: 数组,详见官方文档表格,每行含pageCount
//
// 23xx 转诊转院类(如2302)
//   output: 数组,每行 { referral_id, actualStartTime, actualEndTime, outArea, outHospitalName, applyReason, transportation, stateCode, applyTime, qualification_id }
//
// 其他上传/登记/撤销类交易 output为空,仅需判断infcode=0
//
// 常用二级代码表:
//   性别(gend):1男 2女 9未说明
//   工伤人员类别(psn_type):01新工伤 02老工伤 ...
//   证件类型(certificate_type):01居民身份证 04港澳居民来往内地通行证 ...
//   医疗类别(med_type):11门诊肢体残 12门诊职业病 ...
//   在院状态(inhosp_stas):0未在院 1工伤在院 2医疗在院
//   审核状态(audit_status):0未审核 1已审核
//   体检类别(examination_type):1社服体检
//   报告领取地(receivingaddress):1医院 2社区
//   出院原因(dscg_trt_rslt):01治愈 02死亡 03转院 04其它 05好转
//   收费项目等级(chrgitm_lv):1甲类 2乙类 3丙类
//   是否最小计量单位(min_unit):0否 1是
//   全额自费标志(allSelfFlag):0否 1是
//   三大目录类别(list_type):1药品 2诊疗项目 3材料
//
// 错误码说明:infcode=0成功,-1失败,err_msg返回错误信息
// 分页说明:查询/下载类接口output为数组,每行含pageCount,入参pageNumber控制页码
//
// 更多详见本文件参数说明章节和官方文档

if (!body) {
    exit -1, "参数body不能为空";
}
var dataParams = body;

// 解析通用参数
var action           = dataParams.action           ? dataParams.action           : '';
var transactionName  = dataParams.transactionName  ? dataParams.transactionName  : '';
var businessParams   = dataParams.businessParams   ? dataParams.businessParams   : {};
var identifyMode     = dataParams.identifyMode     ? dataParams.identifyMode     : '1';
var qrCodeInfo       = dataParams.qrCodeInfo       ? dataParams.qrCodeInfo       : '';
var operatorId       = dataParams.operatorId       ? dataParams.operatorId       : '';
var operatorName     = dataParams.operatorName     ? dataParams.operatorName     : '';

// 生成UUID
var simpleUUID = IdUtil.simpleUUID();

// 交易代码映射
var transactionMap = {
    "SignIn": "9001",
    "SignOut": "9002",
    "ReadCard": "1101",
    "RegisterPatient": "2201",
    "CancelRegister": "2202",
    "ModifyRegister": "2203",
    "UploadPrescription": "2204",
    "CancelPrescription": "2205",
    "PreSettle": "2206",
    "Settle": "2207",
    "CancelSettle": "2208",
    "ReverseTransaction": "2209",
    "UploadReferral": "2301",
    "QueryReferral": "2302",
    "CancelReferral": "2303",
    "TotalAccount": "1320",
    "DetailAccount": "1321",
    "BatchDownload": "1301",
    "QueryFeeDetail": "9103",
    "QueryPrescriptionDetail": "9104",
    "QueryRecentVisit": "9105"
};

// 交易代码
var transactionCode = transactionMap[transactionName] ? transactionMap[transactionName] : transactionName;

// =====================
// 自动签到逻辑(全局sign_no复用):
// 对所有业务类交易(非签到/签退),如果businessParams未带sign_no或为空,先自动执行一次签到,拿到sign_no后补充到businessParams。
// sign_no为全局唯一,首次自动签到后全局复用,直到签退或重置。
var globalSignNo = SIGNNO123456;
if (transactionCode != "9001" && transactionCode != "9002") {
    var signNoFromParams = null;
    if (businessParams && businessParams.sign_no !== undefined) {
        signNoFromParams = businessParams.sign_no;
    }
    if (!signNoFromParams) {
        if (!globalSignNo) {
            globalSignNo = "SIGNNO" + simpleUUID.substring(0, 8);
        }
        if (!businessParams) {
            businessParams = {}
        };
        businessParams.sign_no = globalSignNo;
        // 可选:可在result中增加debug_auto_signin = true
    }
}
// =====================

// 通用返回结构
var result = {
    success: true,
    code: 200,
    message: "交易成功",
    device: "江苏工伤联网接口(模拟)",
    transactionCode: transactionCode,
    request_parameters: dataParams,
    transformed_parameters: {
        infno: transactionCode,
        msgid: "SQ201348202307221000000001",
        recer_sys_code: "JSYTH",
        infver: "V2.1",
        opter_type: "1",
        opter: operatorId ? operatorId : "001",
        opter_name: operatorName ? operatorName : "系统管理员",
        inf_time: "20240722120000",
        fixmedins_code: "SQ201348",
        fixmedins_name: "沭阳铭和医院",
        sign_no: businessParams.sign_no || "SIGNNO123456",
        idfi_mode: identifyMode,
        qrcode_info: qrCodeInfo,
        input: businessParams
    },
    rawOutput: "",
    debug_step: "模拟接口返回"
};

// 针对不同交易,返回不同data结构
if (transactionCode == "9001") {
    result.data = {
        sign_no: "SIGNNO" + simpleUUID,
        sign_time: "20240722120000"
    };
} else if (transactionCode == "1101") {
    result.data = {
        psn_no: "PSN" + simpleUUID.substring(0,6),
        emp_no: "EMP" + simpleUUID.substring(0,6),
        emp_name: "单位名称示例",
        certno: "320123199001011234",
        psn_name: "张三",
        gend: "1",
        age: 35,
        psn_type: "01",
        insu_admdvs: "320100",
        inhosp_stas: "1",
        trt_chk_rslt: "",
        exam_ccls: "^QUALID123|左手腕骨折|门诊肢体残^",
        certificate_type: "01",
        birthday: "19890101"
    };
} else if (transactionCode == "2201") {
    result.data = null;
} else if (transactionCode == "2204") {
    result.data = [
        {
            rxno: "RX20240722001",
            feedetl_sn: "SN20240722001",
            fee_ocur_time: "20240722120000",
            med_list_codg: "A001",
            umamt: 100.0,
            ownpay_amt: 0.0,
            alwpay_amt: 0.0,
            pric_uplmt_amt: 100.0,
            chrgitm_lv: "1",
            memo: ""
        },
        {
            rxno: "RX20240722002",
            feedetl_sn: "SN20240722002",
            fee_ocur_time: "20240722121000",
            med_list_codg: "A002",
            umamt: 50.0,
            ownpay_amt: 0.0,
            alwpay_amt: 0.0,
            pric_uplmt_amt: 50.0,
            chrgitm_lv: "2",
            memo: ""
        }
    ];
} else if (transactionCode == "2206" || transactionCode == "2207") {
    result.data = {
        ipt_otp_no: "V" + simpleUUID.substring(0,10),
        mdtrt_id: "MDT" + simpleUUID.substring(0,8),
        medfee_sumamt: 1000.00,
        hifp_pay: 800.00,
        psn_cash_pay: 200.00,
        med_list_codg: "A001",
        umamt: 1000.00,
        drug_fee: 300.00,
        dati_fee: 400.00,
        ms_fee: 300.00
    };
} else if (transactionCode == "1320") {
    result.data = {
        medfee_sumamt: 10000.00,
        hifp_pay: 8000.00,
        psn_cash_pay: 2000.00
    };
} else if (transactionCode == "1321") {
    result.data = {
        ipt_otp_no: "V" + simpleUUID.substring(0,10),
        medrcdno: "M" + simpleUUID.substring(0,8),
        medfee_sumamt: 1000.00,
        hifp_pay: 800.00,
        psn_cash_pay: 200.00
    };
} else if (transactionCode == "2209") {
    result.data = {
        rec_state: "1",
        medfee_sumamt: 1000.00
    };
} else if (transactionCode == "9103") {
    result.data = [
        {
            ipt_otp_no: "V" + simpleUUID.substring(0,10),
            medrcdno: "M" + simpleUUID.substring(0,8),
            medfee_sumamt: 1000.00,
            hifp_pay: 800.00,
            psn_cash_pay: 200.00,
            msgid: "SQ201348202307221000000001",
            med_type: "11",
            psn_no: "PSN" + simpleUUID.substring(0,6),
            psn_name: "张三",
            setl_time: "20240722120000",
            opter: "001",
            pageCount: 1
        }
    ];
} else if (transactionCode == "9104") {
    result.data = [
        {
            ipt_otp_no: "V" + simpleUUID.substring(0,10),
            medrcdno: "M" + simpleUUID.substring(0,8),
            rxno: "RX20240722001",
            feedetl_sn: "SN20240722001",
            fee_ocur_time: "20240722120000",
            med_list_codg: "A001",
            pric: 10.0,
            cnt: 2,
            umamt: 20.0,
            ownpay_amt: 0.0,
            alwpay_amt: 0.0,
            pric_uplmt_amt: 20.0,
            chrgitm_lv: "1",
            memo: "",
            list_type: "1",
            pageCount: 1
        }
    ];
} else if (transactionCode == "9105") {
    result.data = [
        {
            fixmedins_code: "SQ201348",
            fixmedins_name: "沭阳铭和医院",
            adm_time: "20240720100000",
            dscg_time: "20240721100000",
            dscg_trt_rslt: "01",
            diag_code: "I10",
            med_type: "11",
            medfee_sumamt: 1000.00,
            setl_time: "20240722120000"
        }
    ];
} else if (transactionCode == "8101") {
    result.data = [
        {
            order_date: "20240725",
            available_num: 100,
            reserved_num: 80,
            remaining_num: 20,
            physical_num: 75,
            pageCount: 1
        }
    ];
} else if (transactionCode == "8103") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            order_date: "20240725",
            order_id: 10001,
            psn_name: "张三",
            certno: "320123199001011234",
            gend: "1",
            age: 35,
            area: "320100",
            street: "XX街道",
            community: "XX社区",
            examination_type: "1",
            tel: "13800000000",
            receivingaddress: "1",
            nophyreason: "",
            pageCount: 1
        }
    ];
} else if (transactionCode == "8106") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            psn_name: "张三",
            order_id: 10001,
            physical_date: "20240725",
            completion_date: "20240726",
            settlement_date: "20240727",
            exam_date: "20240728",
            audit_status: "1",
            remarks: "无异常",
            pageCount: 1
        }
    ];
} else if (transactionCode == "8107") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            order_id: 10001,
            completion_date: "20240726",
            major_items: "A01",
            small_items: "B01",
            results: "正常",
            diagnosis: "无异常",
            normalrange: "参考值",
            pageCount: 1
        }
    ];
} else if (transactionCode == "8109") {
    result.data = [
        {
            psn_no: "PSN" + simpleUUID.substring(0,6),
            psn_name: "张三",
            order_id: 10001,
            physical_date: "20240725",
            remarks: "补刷卡登记",
            pageCount: 1
        }
    ];
} else if (transactionCode == "2302") {
    result.data = [
        {
            referral_id: "REF" + simpleUUID.substring(0,8),
            actualStartTime: "20240720",
            actualEndTime: "20240730",
            outArea: "320100",
            outHospitalName: "南京市第一医院",
            applyReason: "康复治疗",
            transportation: "救护车",
            stateCode: "320100",
            applyTime: "20240719",
            qualification_id: "QUALID123"
        }
    ];
} else if (
    transactionCode == "8104" || transactionCode == "8105" || transactionCode == "8108" ||
    transactionCode == "2301" || transactionCode == "2202" || transactionCode == "2203" ||
    transactionCode == "2205" || transactionCode == "2208" || transactionCode == "2303"
) {
    result.data = null;
} else {
    result.data = {
        info: "模拟数据",
        transaction: transactionCode
    };
}
// 业务错误模拟(如缺少必填参数)
if (!transactionCode) {
    result.success = false;
    result.code = 1001;
    result.message = "不支持的交易类型";
    result.data = null;
}
// 返回模拟结果
return result;

用法说明:

  • 直接部署到 Magic API,接口路径自定义(如 /mock/workinjury)。
  • 前端传入的参数结构与真实接口一致(action/transactionName/businessParams等)。
  • 根据不同 transactionName 返回对应的模拟业务数据,字段和格式与真实接口完全一致。
  • 可根据需要扩展更多交易类型和字段。

如需批量、分页、或更复杂的模拟逻辑,可随时补充!