第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

示例描述:

  经过前面章节的课程,对Mirth Connect在系统集成与数据交互中的使用有了一个大概的了解;大家一定有个疑惑,Mirth Connect如何组织响应消息并返回给调用者?今天我们就来继续深入讲解Response响应处理机制。

C#示例:

  本课程我们将通过C#编程语言调用Mirth Connect接口服务来讲述,C#示例截图如下:

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

C#测试客户端

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

C#版本Webservice接口服务

TCP Listener 信道示例:

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

新建信道并设置源端输入输出参数格式、目的端输入输出格式、响应输入输出参数格式

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

设置源端TCP Listener参数

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

设置目的端Channel Writer参数

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

设置源端转换规则

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

源端新建JS转换步骤,在‘输入消息模板’录入如下HL7消息模板并添加如下js脚本

MSH|^~\&|SMS|IAH|CERNER|PATHNT|200201291848||ADT^A01|CHPFADIT|P|2.3|||AL|NE|
EVN|A01|200201291848|||REJKB1
PID||53820452|00664524|220675537|AHMED^AYALNE^^^^||19781218|M||E|5718 SEMINARY RD #B5^^FALLS CHURCH^VA^22041||(703)379-8374|||||0053820452|220675537||
PV1||I|2324^2302^-B ||||1111111^PINA|||MED|||||||1111111^PINA|S||S|P||||||||||||||||||IAH|||||200201291848|
PV2|||^SEIZURE, FEVER, RLQ PAIN

var dbConn;
try {
      var pid=msg['PID']['PID.2']['PID.2.1'].toString();
      var name=msg['PID']['PID.5']['PID.5.2'].toString();
      var sex=msg['PID']['PID.8']['PID.8.1'].toString();
      var dob=msg['PID']['PID.7']['PID.7.1'].toString();
      var addr=msg['PID']['PID.11']['PID.11.3'].toString();
      var ssn=msg['PID']['PID.19']['PID.19.1'].toString();
      channelMap.put('pid',pid);
     dbConn=DatabaseConnectionFactory.createDatabaseConnection('org.mariadb.jdbc.Driver', 'jdbc:mariadb://127.0.0.1:3306/mirthtestdb', 'root', '125353Ct');
      var result=dbConn.executeCachedQuery("select count(*) from  patient WHERE pid = "+pid);
     result.next();
      var icount = result.getInt(1);
      if(icount==0)
      {
         var expression = "INSERT INTO patient (pid,name,sex,dob,addr,ssn) VALUES (?,?,?,?,?,?)";
         var paramList=new Array(pid,name,sex,dob,addr,ssn);
        icount = dbConn.executeUpdate(expression, paramList);
        channelMap.put('Ret','1');
      }else{
          channelMap.put('Ret','0');
      }
      result.close();
} finally {
     if (dbConn) {
         dbConn.close();
     }
}

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

目的端响应转换规则

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

在‘输出消息模板’中录入如下xml格式模板并添加如下js脚本

<patient>
<pid></pid>
<ret></ret>
</patient>

tmp['pid']=$('pid');
tmp['ret']=$('Ret');

第六課-Channel Study For TCP Listener & HTTP Listener & Web Service Listener About Response Handler

运行C#版TCP Sender,进行如上测试,成功获取响应,验证Mirth Connect 的TCP Listener信道OK!


上一篇:windows terminal 简单美化


下一篇:Vue的路由懒加载的方式