1. Resumo

 

Ainda há sistemas legados na área da saúde que usam PB9, Delphi7 e outras linguagens. Para acelerar o processo de desenvolvimento e permitir que aplicativos de terceiros invoquem o webservice HL7 V2 integrado fornecido pelo Ensemble ou IRIS assim que possível, apresentamos aqui vários exemplos de invocação da interface SOAP HL7 V2 do Ensemble usando Java, PB9 e Delphi7.

 

Presumindo que EnsLib.HL7.Service.SOAPService.CLS, um Serviço integrado, é adicionado à produção e nomeado PeiXunHl7SoapIn, o sistema externo pode acessar o webservice SOAP HL7 V2 pelo seguinte endpoint.

 

 

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

CfgItem=PeiXunHl7SoapIn é um parâmetro importante, PeiXunHl7SoapIn é o nome do BS (Serviço).

Com o parâmetro CfgItem, você pode acessar interfaces SOAP implementadas pela mesma classe de Serviço, mas expostas com nomes diferentes. Por exemplo, adicionando outro Serviço SOAP com o mesmo nome V2Service e acessando pelo endpoint

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

levará ao recém-adicionado Serviço.

Exemplos de acesso à interface SOAP usando Java, PB9 e Delphi7 são mostrados na próxima seção. Outras linguagens sem exemplos também podem chamar o Webservice SOAP V2 por esse endpoint.

Dica: preste atenção à definição do separador de segmento HL7 V2 em diferentes linguagens, que está marcado nos exemplos de código a seguir, por exemplo, PB usa char(13)+char(10) como o retorno e Delphi usa #13+#10 para a quebra de linha.
 
  1. Amostras

         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;