Menu

#101 Get message type (ADT, ORU etc) before parsing the message.

Future
open
nobody
None
2
2019-01-18
2019-01-17
No

Need to get message type(ADT,ORU tec) before parsing this, is there any way ? Currently after parsing the message to Message Class object we can get its version & Type (ORU, ADT etc)

Like:
public static String getMsgStructureName(String msgStr, HapiContext context){
String structureName = null;

// context.setModelClassFactory(mcf);
PipeParser parser = context.getPipeParser();

    Message msg;
    try {
        msg = parser.parse(msgStr);

        structureName = msg.getName();

    **  System.out.println("Message Version: "+msg.getVersion());
        System.out.println("Message Structure: "+msg.getName());**
    } catch (HL7Exception e) {
        e.printStackTrace();
    }

    return structureName;
}

I want to get before this line

msg = parser.parse(msgStr);

Discussion

  • Christian Ohr

    Christian Ohr - 2019-01-17

    There is ca.uhn.hl7v2.preparser.PreParser.getFields(msg, fields...) that returns the value of fields without parsing it into a structure. Check out the javadocs

     

    Last edit: Christian Ohr 2019-01-17
  • Anjum Pervaiz

    Anjum Pervaiz - 2019-01-18

    Thanks Christian Ohr

     

Log in to post a comment.