Hello Edgard,

If your application should only convert XMLHL7 messages into classic HL7 messages you do not need an explicit cast to a special kind or version of message.
Just use the ca.uhn.hl7v2.model.Message interface

       ca.uhn.hl7v2.model.Message msg = xmlParser.parse(xmlMessage);
       String hl7Message = classicParser.encode(msg);

But the real question is: what do you want to do ?

bye,
Marco Montel


Edgar Magaña Perdomo ha scritto:
Hello Marco,

What I discovered (probably I am wrong) is that when you are
converting from XML to HL7 messages you need to specify the "import
classes" corresponding to the version of the HL7 messages in the XML
file. I have also found that you need to specify the "type" of message
that is going to be converted (e.g. ADT_A01 or QRY_R02). In the
following example you can convert just a QRY_R02 XML file to the HL7
2.2 version. If the XML file indicates a different version or type
of message this code will not work.
Do you know if it is the only way to parsing or there is one more
generic. Because, I will have to implement five classes (one per HL7
version) and define all the type of messages and they are so many..
:-(


import ca.uhn.hl7v2.model.v22.message.*;
import ca.uhn.hl7v2.parser.*;

  public class TransformingXMLtoHL7Msg  {
      /**
       * A simple example of parsing a message
       */
        
          public String changeEncoding(String inXMLMessage)
          {
                          DefaultXMLParser XParser = new DefaultXMLParser();
                          PipeParser classicParser = new PipeParser();
                          String classicMessage = null;
                          QRY_R02 msg = null;
        
                          try{

                                  msg = (QRY_R02)XParser.parse(inXMLMessage);
                                  classicMessage = classicParser.encode(msg);
                          }
                          catch (Exception e) {
                              e.printStackTrace();
                          }
                  return classicMessage;
          }
     }

Kind Regards,

Edgar Magana

On 2/19/08, Marco Montel <[EMAIL PROTECTED]> wrote:
Hello Edgar,

You can try using the MyXMLParser implementation of XMLParser.

       ca.uhn.hl7v2.parser.XMLParser xmlParser = new
ca.uhn.hl7v2.parser.MyXMLParser();
       ca.uhn.hl7v2.model.Message msg = xmlParser.parse(xmlMessage);


bye,
Marco Montel

Edgar Magaña Perdomo ha scritto:
Hello Folks,

 I am new working on HAPI and I would like to know if it has
 implemented the parser from XML to HL7 messages. I know that is
 implemented the one from HL7 to XML but I am not sure for the other
 way.

 Thanks in advance,

 Edgar

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to