应用添加监听请求运算事件

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";//填充计算结果
    //使用"onlyFill"告知编辑器,计算已经完成,只进行内容填充显示过程
    cfg.pass_app_msg = "onlyFill";//interrupt、onlyFill
    ThinkEditor.SetDocConfig(doc_name, cfg);

参考应用代码

methods: {
    OnAlgorithmCalc(e){
        console.log('OnAlgorithmCalc');
        var data = e.data;
        if(data.type="algorithmCalc" && data.handle == "request")
        {
            //if(data.group == "calc_total")根据算集名进行自定义计算
            var doc_name = data.name;
            /*********************
            *********************
            [略]用户可根据data中的算法集信息和选框、元素的信息进行自定义计算            
            *********************
            ******************/            
            var cfg={};
            cfg.pass_app_result = "2.13";//填充计算结果
            //使用"onlyFill"告知编辑器,计算已经完成,只进行内容填充显示过程
            cfg.pass_app_msg = "onlyFill";//interrupt、onlyFill
            ThinkEditor.SetDocConfig(doc_name, cfg);
        }

        return true;
    },

效果

文档更新时间: 2022-05-19 18:08   作者:admin