应用添加监听请求运算事件
ThinkEditor.addEventListener("algorithmCalc", this.OnAlgorithmCalc);
事件数据
{
"handle": "request",
"type": "algorithmCalc",
"name": "张小北-入院记录",
"group": "calc_total",
"mode": 1,
"scope": 0,
"inObjects": [
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 1.000000,
"checked": 0,
"optionClass": "UserDefine",
"optionId": "age_range",
"optionName": "",
"groupId": "1",
"itemId": "年龄大于60岁"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 0.000000,
"checked": 1,
"optionClass": "UserDefine",
"optionId": "age_range",
"optionName": "",
"groupId": "1",
"itemId": "年龄小于60岁"
},
{
"type": "CheckBox",
"id": "003",
"name": "高血压",
"algoRole": 0,
"weight": 1.000000,
"checked": 1
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 2.000000,
"checked": 0,
"optionClass": "UserDefine",
"optionId": "symptom",
"optionName": "",
"groupId": "1",
"itemId": "单侧无力"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 1.000000,
"checked": 1,
"optionClass": "UserDefine",
"optionId": "symptom",
"optionName": "",
"groupId": "1",
"itemId": "不伴有无力的语言障碍"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 0.000000,
"checked": 0,
"optionClass": "UserDefine",
"optionId": "symptom",
"optionName": "",
"groupId": "1",
"itemId": "无"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 2.000000,
"checked": 0,
"optionClass": "UserDefine",
"optionId": "time",
"optionName": "",
"groupId": "1",
"itemId": ">60分钟"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 1.000000,
"checked": 0,
"optionClass": "UserDefine",
"optionId": "time",
"optionName": "",
"groupId": "1",
"itemId": "10-59分钟"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 0.000000,
"checked": 1,
"optionClass": "UserDefine",
"optionId": "time",
"optionName": "",
"groupId": "1",
"itemId": "<10分钟"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 1.000000,
"checked": 0,
"optionClass": "UserDefine",
"optionId": "have",
"optionName": "",
"groupId": "1",
"itemId": "有"
},
{
"type": "CheckBox",
"id": "",
"name": "",
"algoRole": 0,
"weight": 0.000000,
"checked": 1,
"optionClass": "UserDefine",
"optionId": "have",
"optionName": "",
"groupId": "1",
"itemId": "无"
}
],
"outObjects": [
{
"type": "Element",
"id": "013",
"name": "ABCD2评估总分",
"algoRole": 1,
"content": "12"
}
]
}
字段含义
| 字体 |
必填 |
类型 |
说明 |
备注 |
| name |
是 |
sting |
文档名 |
|
| group |
是 |
sting |
运算集 名 |
用户自定义,用于区分不同运算集合 |
| mode |
是 |
emun |
运算模型 |
算法模型 |
| scope |
是 |
emun |
运算范围 |
算法范围 |
| inObjects |
是 |
json arr |
输入对象列表 |
用于计算的输入对象的详见信息 |
| outObjects |
是 |
json arr |
输出对象列表 |
用于结果显示的输出对象的详见信息 |
- 一般使用E_ALGO_MODE::Common来表示用户自定义算法
- 内置算法也能使用本方法进行接管
inObjects/outObjects参数
通用参数
| 字体 |
必填 |
类型 |
说明 |
备注 |
| type |
是 |
sting |
CheckBox 或 Element |
|
| id |
是 |
sting |
选框Id |
|
| name |
是 |
sting |
选框Name |
|
| algoRole |
是 |
emun |
角色 |
算法角色 |
选框参数
主要关注
- weight 对应的权值
- checked 是否被选中
| 字体 |
必填 |
类型 |
说明 |
备注 |
| weight |
是 |
float |
权值 |
选框依赖该值进行数值运算 |
| checked |
是 |
bool |
是否选中 |
0:未选中 1:选中 |
| optionClass |
否 |
sting |
选项类 |
(属于选集时才有本字段) |
| optionId |
否 |
sting |
选项ID |
(属于选集时才有本字段) |
| optionName |
否 |
sting |
选集名 |
(属于选集时才有本字段)用户自定义,用于某些场景 区分同一个病历中使用相同选项组,但又属于不同联动状态的两个选集实例 |
| optionId |
否 |
sting |
选项组 |
(属于选集时才有本字段)同一个选集内,选项之间互斥时使用 |
| itemId |
否 |
sting |
选项ID |
(属于选集时才有本字段)在选集中的单项ID |
元素参数
主要关注
- content 对应元素内容,如果为数值可自行转换为数值进行计算
| 字体 |
必填 |
类型 |
说明 |
备注 |
| content |
是 |
string |
元素内容 |
根据自己定义的应用场景,可转换为数值使用 |
运算结果的返回
- 通过SetDocConfig()接口传递运算状态和运算结果信息。
- 不关心的运算请求-应用直接返回true即可
| 参数名 |
必填 |
类型 |
说明 |
备注 |
| pass_app_result |
否 |
string |
传递应用结果 |
主要应用于自定义运算场景 |
| pass_app_msg |
否 |
string |
传递应用消息 |
主要应用于自定义运算场景,”interrupt”:表示中止编辑器内置运算流程 “onlyFill”:表示使用应用传递的运算结果,由编辑器继续执行自动填充显示结果流程 |
示例代码
var cfg={};
cfg.pass_app_result = "2.13";
cfg.pass_app_msg = "onlyFill";
ThinkEditor.SetDocConfig(doc_name, cfg);
参考应用代码
methods: {
OnAlgorithmCalc(e){
console.log('OnAlgorithmCalc');
var data = e.data;
if(data.type="algorithmCalc" && data.handle == "request")
{
var doc_name = data.name;
var cfg={};
cfg.pass_app_result = "2.13";
cfg.pass_app_msg = "onlyFill";
ThinkEditor.SetDocConfig(doc_name, cfg);
}
return true;
},
效果

文档更新时间: 2025-10-10 11:23 作者:admin