Article
· Sep 9, 2022 5m read

How to call Ensemble/IRIS built-in HL7 V2 webservice - Java, PB9, Delphi7 samples

  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://localhost:57772/csp/peixunpro/EnsLib.HL7.Service.SOAPService.CLS?CfgItem=PeiXunHl7SoapIn

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 Java

  1. package hl7.send;
    
    import java.rmi.RemoteException;
    import javax.xml.rpc.ParameterMode;
    import javax.xml.rpc.ServiceException;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.XMLType;
    
    public class SendHl7MSG{
        public String invokeRemoteFuc() {
           String endpoint ="http://localhost:57772/csp/peixunpro/EnsLib.HL7.Service.SOAPService.CLS?CfgItem=PeiXunHl7SoapIn";
            String result = "no result!";
            Service service = new Service();
            Call call;
            Object[] object = new Object[1];
            // Notice the line break  
            String s1 = "\r\n";
            
            String str="MSH|^~\\&|HIS|MediInfo|MediII|MediInfo|20150118162159||SIU^S12|145d03160de54b29a74eefa761ae4e05|P|2.4"+s1+"SCH||A1002||||(原因)正常预约|||||^^^07:11~07:22^^^^07:11~07:22|||||||||||||||112211522"+s1+"RGS|||";
            object[0]= str;
            try {
                call = (Call) service.createCall();
                call.setTargetEndpointAddress(endpoint);// Remote call path
                call.setOperationName("Send");// Method to be invoked
                // Set the parameters
                call.addParameter("Input", // Parameter name
                        XMLType.XSD_STRING,// Parameter type:String
                        ParameterMode.IN);// Parameter mode:'IN' or 'OUT'
                // Set the return value type:
                call.setReturnType(XMLType.XSD_STRING);// Return type:String          
                result = (String) call.invoke(object);// Remote call
            } catch (ServiceException e) {
                e.printStackTrace();
            } catch (RemoteException e) {
                e.printStackTrace();
            }
            return result;
        }
        public static void main(String[] args) {
            SendHl7MSG t = new SendHl7MSG();
            String result=null;
            result = t.invokeRemoteFuc();
            System.out.println(result);
        }
    }

 

  1.  

2.2 PB 9

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

 

2.3 Delphi 7

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

Discussion (1)2
Log in or sign up to continue