HISUI
iMedical发布开放式Restful
2022年10月17日 15时55分

1. 维护对外接口

使用管理员进入侧菜单-【系统接口管理】界面,新建或修改接口
接口管理

2. 访问restful路径

得到的restful路径为:https://ip:port/imedical/rest/open/接口代码

如:
https://ip:port/imedical/rest/open/getMenu路径,body-json方式可以访问
restful

3. 调用对应类方法

当访问第2点的restful时,会进入M中维护好的对外接口中的类方法,入参为restful的JsonBody数据
示例一:

    ClassMethod GetMenu(JsonBody = "")
    {
        // JsonBody内容: {"Request":{"Data":{["roleCode": "住院医师"]}}}
        // 且会解析JSON字符串得到进程Global以便使用
        // ^||BodyJson("Request","Data",0,"roleCode")="住院医师"
    }

示例二:

    ClassMethod GrantMenu(BodyJson = "")
    {
        Set RetObj =##class(BSP.SYS.DTO.HosBase).%New() // 与HOS对接时返回值JSON对象基础类
        Set GroupCode = ^||BodyJson("Request","Data",0,"roleCode")
        Set GroupId = ##class(web.SSGroup).GetIdFromCodeOrDescription(GroupCode)
        If GroupId'>0 Set RetObj.msg="not find group",RetObj.code=400 Quit RetObj
        //赋权菜单
        Set Ind="" for {
            Set Ind = $o(^||BodyJson("Request","Data",0,"perms",Ind))
            Quit:Ind=""
            Set PermMenuGrant = ^||BodyJson("Request","Data",0,"perms",Ind)
            //省略代码...
        }
        //保存
        set sc=objEprGroupSetting.%Save()
        if $$$ISERR(sc) {
            Set RetObj.msg=$system.Status.GetErrorCodes(sc),RetObj.code=400
            Quit RetObj
        }
        Quit RetObj  //平台会转成JSON字符串
    }
上一篇: 下一篇:

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

访问量: 379547