1. Summary

 

There are still legacy systems in the healthcare industry that use PB9, Delphi7, and other languages. To speed up the development process and enable third party applications to invoke the build-in HL7 V2 webservice provided by Ensemble or IRIS ASAP, we provide here several examples of invocations of Ensemble's HL7 V2 SOAP interface using Java, PB9 and Delphi7.

 

Assuming that EnsLib.HL7.Service.SOAPService.CLS, a build-in Business Service, is added to Production and named PeiXunHl7SoapIn, the external system can access HL7 V2 SOAP webservice through the following endpoint.

 
http:<span class="hljs-comment">//localhost:57772/csp/peixunpro/EnsLib.HL7.Service.SOAPService.CLS?CfgItem=PeiXunHl7SoapIn</span>

CfgItem=PeiXunHl7SoapIn is an important parameter, PeiXunHl7SoapIn is the name of your BS.

With the parameter CfgItem, you can access SOAP interfaces that are deployed by the same Business Service class, but exposed under different names. For example, adding another SOAP Business Service with the same name V2Service, then accessing through the endpoint

http://localhost:57772/csp/peixunpro/EnsLib.HL7.Service.SOAPService.CLS?CfgItem=V2Service

will brought to the newly added Business Service.

Examples accessing this SOAP interface using Java, PB9 and Delphi7 are shown in the next section. Other languages without examples can also call the V2 SOAP Webservice via such an endpoint.

Tip: Pay attention to the definition of HL7 V2 Segment separator in various languages, which is marked in the following code examples, e.g. PB uses char(13)+char(10) as carriage return, and Delphi uses #13+#10 for line break.
 
  1. Samples
**         2.1 J****ava**
  1. <span class="hljs-keyword">package</span> hl7.send;
    
    <span class="hljs-keyword">import</span> java.rmi.RemoteException;
    <span class="hljs-keyword">import</span> javax.xml.rpc.ParameterMode;
    <span class="hljs-keyword">import</span> javax.xml.rpc.ServiceException;
    <span class="hljs-keyword">import</span> org.apache.axis.client.Call;
    <span class="hljs-keyword">import</span> org.apache.axis.client.Service;
    <span class="hljs-keyword">import</span> org.apache.axis.encoding.XMLType;
    
    <span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SendHl7MSG</span></span>{
        <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">invokeRemoteFuc</span><span class="hljs-params">()</span> </span>{
           String endpoint =<span class="hljs-string">"http://localhost:57772/csp/peixunpro/EnsLib.HL7.Service.SOAPService.CLS?CfgItem=PeiXunHl7SoapIn"</span>;
            String result = <span class="hljs-string">"no result!"</span>;
            Service service = <span class="hljs-keyword">new</span> Service();
            Call call;
            Object[] object = <span class="hljs-keyword">new</span> Object[<span class="hljs-number">1</span>];
            <span class="hljs-comment">// Notice the line break  </span>
            String s1 = <span class="hljs-string">"\r\n"</span>;
            
            String str=<span class="hljs-string">"MSH|^~\\&|HIS|MediInfo|MediII|MediInfo|20150118162159||SIU^S12|145d03160de54b29a74eefa761ae4e05|P|2.4"</span>+s1+<span class="hljs-string">"SCH||A1002||||(原因)正常预约|||||^^^07:11~07:22^^^^07:11~07:22|||||||||||||||112211522"</span>+s1+<span class="hljs-string">"RGS|||"</span>;
            object[<span class="hljs-number">0</span>]= str;
            <span class="hljs-keyword">try</span> {
                call = (Call) service.createCall();
                call.setTargetEndpointAddress(endpoint);<span class="hljs-comment">// Remote call path</span>
                call.setOperationName(<span class="hljs-string">"Send"</span>);<span class="hljs-comment">// Method to be invoked</span>
                <span class="hljs-comment">// Set the parameters</span>
                call.addParameter(<span class="hljs-string">"Input"</span>, <span class="hljs-comment">// Parameter name</span>
                        XMLType.XSD_STRING,<span class="hljs-comment">// Parameter type:String</span>
                        ParameterMode.IN);<span class="hljs-comment">// Parameter mode:'IN' or 'OUT'</span>
                <span class="hljs-comment">// Set the return value type:</span>
                call.setReturnType(XMLType.XSD_STRING);<span class="hljs-comment">// Return type:String          </span>
                result = (String) call.invoke(object);<span class="hljs-comment">// Remote call</span>
            } <span class="hljs-keyword">catch</span> (ServiceException e) {
                e.printStackTrace();
            } <span class="hljs-keyword">catch</span> (RemoteException e) {
                e.printStackTrace();
            }
            <span class="hljs-keyword">return</span> result;
        }
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
            SendHl7MSG t = <span class="hljs-keyword">new</span> SendHl7MSG();
            String result=<span class="hljs-keyword">null</span>;
            result = t.invokeRemoteFuc();
            System.out.println(result);
        }
    }

 

  •  
  • 2.2 PB 9

    String endPoint=<span class="hljs-string">"http://192.168.2.64:57772/csp/jhip/EnsLib.HL7.Service.SOAPService.cls?CfgItem=HISHL7SoapIn"</span>
    soapconnection lsc_conn <span class="hljs-comment">//Obtain the SOAP class </span>
    hl7v2servicesoap lsrv_obj   <span class="hljs-comment">//Get wsdl                                                                                                       </span>
    lsc_conn =create soapconnection   
    <span class="hljs-comment">// Instantiating with the EndPoint provided by Ensemble, </span>
    <span class="hljs-comment">// i.e., adding the name of the CfgItem configuration </span>
    lsc_conn.createinstance(lsrv_obj,<span class="hljs-string">"hl7v2servicesoap"</span>,endPoint)   
    <span class="hljs-comment">//PB使用char(13)+char(10) as a line break</span>
    <span class="hljs-comment">// Also notice that the ~ character is an escape character in PB and is also a separator in HL7, so two ~'s are used in PB to represent one singe HL7 V2 separator</span>
    string msg=<span class="hljs-string">""</span>
    msg=<span class="hljs-string">"MSH|^~~\&|HIS||JHIP||20150119163230||ADT^A01^ADT_A01|8E64C7FE-7750-482E-BC58-DC358FF0A05|P|2.4||||||UTF8"</span>+char(<span class="hljs-number">13</span>)+char(<span class="hljs-number">10</span>)
    msg+=<span class="hljs-string">"EVN||20150119163230|||2341^张医生|20150119163230"</span>
    msg+=char(<span class="hljs-number">13</span>)+char(<span class="hljs-number">10</span>)+<span class="hljs-string">"PID|1||685923^^^^PI~~2^^^^VN||张三^^ZhangSan||19610524000000|M||AB|开拓路^海淀区^北京^ 北京市^100085^^B||^^^^^^13868108756|^^^^^^13868108756||M^已婚||||||12^汉族||||CHN^中国|||||||||||||北京信息技术有限公司|软件工程师NK1|1||BRO||||||||||电业局|||||||||||||||||李四^^lisi|^^^^^^13723412432|四季青路7号^海淀区^北京^北京市^100097"</span>
    msg+=char(<span class="hljs-number">13</span>)+char(<span class="hljs-number">10</span>)+<span class="hljs-string">"PV1|1|I|A30600^^306007^10108&内分泌专科|U|||225^郭四|||||||7||Y|225^郭四四|84|10030791|||||||||||||||||||||||10108||20150119162910|||8000||7000DG1|1||E11.900^2型糖尿病||20160728170353|A"</span>
    mle_2.text=lsrv_obj.send(msg)            <span class="hljs-comment">// Method call      </span>
    
     

    2.3 Delphi 7

    procedure TForm1.Button1Click(Sender: TObject);
    <span class="hljs-keyword">var</span>
      mHttpRIO: THTTPRIO;
      mServiceSoap: HL7v2ServiceSoap;
      msg: <span class="hljs-built_in">String</span>;
      result:<span class="hljs-built_in">String</span>;
    begin
      mHttpRIO := THTTPRIO.Create(nil);
      <span class="hljs-keyword">try</span>
        <span class="hljs-comment">// Set the URL with the CfgItem configuration item to EndPoint</span>
        mHttpRIO.URL := <span class="hljs-string">'http://192.168.2.64:57772/csp/jhip/EnsLib.HL7.Service.SOAPService.cls?CfgItem=HISHL7SoapIn'</span>;
        mHttpRIO.HTTPWebNode.UseUTF8InHeader := <span class="hljs-literal">true</span>;  <span class="hljs-comment">// Add this line to specify that UTF-8 code transmission is used</span>
        mHttpRIO.Converter.Encoding:=<span class="hljs-string">'UTF-8'</span>;
        mServiceSoap := mHttpRIO <span class="hljs-keyword">as</span> HL7v2ServiceSoap
        <span class="hljs-comment">// The line break in Delphi is #13+#10</span>
        msg:=<span class="hljs-string">'MSH|^~\&|HIS||JHIP||20150119163230||ADT^A01^ADT_A01|8E64C7FE-7750-482E-BC58-DC358FF0A05|P|2.4||||||UTF8'</span>+#<span class="hljs-number">13</span>+#<span class="hljs-number">10</span>;
        msg:=msg+<span class="hljs-string">'EVN||20150119163230|||2341^张医生|20150119163230'</span>;
        msg:=msg+#<span class="hljs-number">13</span>+#<span class="hljs-number">10</span>+<span class="hljs-string">'PID|1||685923^^^^PI~~2^^^^VN||张三^^ZhangSan||19610524000000|M||AB|开拓路^海淀区^北京^ 北京市^100085^^B|'</span>;
        msg:=msg+<span class="hljs-string">'|^^^^^^13868108756|^^^^^^13868108756||M^已婚||||||12^汉族||||CHN^中国|||||||||||||北京信息技术有限公司|软件工程师NK1|1||BRO||||||||||电业局|||||||||||||||||李四^^lisi|^^^^^^13723412432|四季青路7号^海淀区^北京^北京市^100097'</span>;
        msg:=msg+#<span class="hljs-number">13</span>+#<span class="hljs-number">10</span>+<span class="hljs-string">'PV1|1|I|A30600^^306007^10108&内分泌专科|U|||225^郭四|||||||7||Y|225^郭四四si|84|10030791|||||||||||||||||||||||10108||20150119162910|||8000||7000DG1|1||E11.900^2型糖尿病||20160728170353|A'</span>;
        result:=mServiceSoap.Send(msg);<span class="hljs-comment">// Calling methods in the webService</span>
        showmessage(result) ;
        Memo2.Text:=result;
      except
      end;