Hi Ian,
Thanks for the lead. Actually as of now we are not dealing with z-segments
much but I guess your process will help us eventually when we get there. I
resolved my problem in the following way.
Actually it was my bad that I was trying to access the IN1 segment directly
from the ADT_A01 message. Instead I got hold of the Insurance group first
and subsequently retrieved the IN1 and IN2 segment from the group.
Below is the code segment:
ADT_A01_INSURANCE insGroup = null;
Message adtMsg = exchange.getIn().getBody(Message.class); //(Apache Camel
HL7)
insGroup = (ADT_A01_INSURANCE)adtMsg.get("INSURANCE");
if(insGroup != null && !insGroup.isEmpty()) {
in1 = insGroup.getIN1();
in2 = insGroup.getIN2();
in3 = insGroup.getIN3();
}
Regards
Sumit
On Thu, May 30, 2013 at 5:47 PM, Ian Vowles <[email protected]>wrote:
> I overcame this issue by creating a GENERIC_ADT message using techniques
> shown on the Hapi site. Our establishment has many Z-segments, so I had to
> do all those, and group them accordingly. A basic example is available on
> the Hapi site at
> http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/CustomModelClasses.html
>
> Snippets from the objects are shown below. It was quite a long repetitive
> process, and I even wrote a module that created java code from a text file
> for the Z segments. However, now it's done all that is required is to
> create a GENERIC_ADT with it's constructor, and parse the message text with
> it's parse method.
>
> The groups shown in this snippet were defined in similar manner as
> additional classes in the java project.
>
> Hope this helps
> Ian
>
> --- code snippets ---
> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
> package au.gov.qld.health.sit.hl7;
>
> import ca.uhn.hl7v2.HL7Exception;
> import ca.uhn.hl7v2.model.AbstractMessage;
> import ca.uhn.hl7v2.model.v24.segment.*;
> import ca.uhn.hl7v2.parser.ModelClassFactory;
>
> /**
> *
> * @author VowlesI
> */
> public class GENERIC_ADT extends AbstractMessage {
>
> public GENERIC_ADT(ModelClassFactory factory) throws HL7Exception {
> super(factory);
> Class<MSH> addMsh = MSH.class;
> this.add(addMsh,true,false);
> Class<EVN> addEvn = EVN.class;
> this.add(addEvn, false, false);
> Class<SCH> addSch = SCH.class;
> this.add(addSch, false, false);
> Class<PID> addPid = PID.class;
> this.add(addPid, true, false);
> Class<PD1> addPd1 = PD1.class;
> this.add(addPd1, false, false);
> .
> . snip .
> .
> .
> Class<MASTERFILE> addMasterFile = MASTERFILE.class;
> this.add(addMasterFile,false,false);
> Class<ZHBCIS> addZhbcis = ZHBCIS.class;
> this.add(addZhbcis, false, false);
> Class<ZNORM> addZnorm = ZNORM.class;
> this.add(addZnorm, false, false);
> }
>
> public MSH getMSH() throws HL7Exception {
> return (MSH) get("MSH");
> }
>
> public EVN getEVN() throws HL7Exception {
> return (EVN) get ("EVN");
> }
>
> public SCH getSCH() throws HL7Exception {
> return (SCH) get ("SCH");
> }
>
> public PID getPID() throws HL7Exception {
> return (PID) get ("PID");
> }
>
> public PD1 getPD1() throws HL7Exception {
> return (PD1) get ("PD1");
> }
> .
> . snip
> .
> .
>
> public MASTERFILE getMASTERFILE() throws HL7Exception {
> return (MASTERFILE) get ("MASTERFILE");
> }
>
> public ZHBCIS getZHBCIS() throws HL7Exception {
> return (ZHBCIS) get ("ZHBCIS");
> }
>
> public ZNORM getZNORM() throws HL7Exception {
> return (ZNORM) get ("ZNORM");
> }
>
> }
>
>
>
> >>> Sumit Lahiri <[email protected]> 31/05/13 0:45 >>>
> Hello there,
>
> I'm new to HAPI. The problem I'm facing is I'm not able to typecast a ADT
> message to generic ADT_AXX message type. So as a result when I try to parse
> a segment eg. IN1 which is not present in a specific ADT Event type(eg
> ADT_A01) I get an HL7Exception like
>
> "IN1 does not exist in the group ca.uhn.hl7v2.model.v251.message.ADT_A01"
>
> I'm using the following code to parse my message
>
> HapiContext context = new DefaultHapiContext();
> Parser p = context.getGenericParser();
>
> Message hapiMsg;
> try {
> // The parse method performs the actual parsing
> hapiMsg = p.parse(msg1);
> } catch (EncodingNotSupportedException e) {
> e.printStackTrace();
> return;
> } catch (HL7Exception e) {
> e.printStackTrace();
> return;
> }
>
> Any help would be highly appreciated.
>
> Best Regards
> Sumit
>
>
> ********************************************************************************
>
> This email, including any attachments sent with it, is confidential and
> for the sole use of the intended recipient(s). This confidentiality is not
> waived or lost, if you receive it and you are not the intended
> recipient(s), or if it is transmitted/received in error.
>
> Any unauthorised use, alteration, disclosure, distribution or review of
> this email is strictly prohibited. The information contained in this email,
> including any attachment sent with it, may be subject to a statutory duty
> of confidentiality if it relates to health service matters.
>
> If you are not the intended recipient(s), or if you have received this
> email in error, you are asked to immediately notify the sender by telephone
> collect on Australia +61 1800 198 175 or by return email. You should also
> delete this email, and any copies, from your computer system network and
> destroy any hard copies produced.
>
> If not an intended recipient of this email, you must not copy, distribute
> or take any action(s) that relies on it; any form of disclosure,
> modification, distribution and/or publication of this email is also
> prohibited.
>
> Although Queensland Health takes all reasonable steps to ensure this email
> does not contain malicious software, Queensland Health does not accept
> responsibility for the consequences if any person's computer inadvertently
> suffers any disruption to services, loss of information, harm or is
> infected with a virus, other malicious computer programme or code that may
> occur as a consequence of receiving this email.
>
> Unless stated otherwise, this email represents only the views of the
> sender and not the views of the Queensland Government.
>
>
> **********************************************************************************
>
>
>
>
> ------------------------------------------------------------------------------
> Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
> Get 100% visibility into your production application - at no cost.
> Code-level diagnostics for performance bottlenecks with <2% overhead
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap1
> _______________________________________________
> Hl7api-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>
>
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel