Hi Michael,
It definitely looks like you're right, thanks for the detailed explanation!
I've put in a bug about this as well:
https://sourceforge.net/tracker/index.php?func=detail&aid=3558962&group_id=38899&atid=423835
I assume you already noticed this, but if you call your class ZDT_A01 you
see the issue you are mentioning, but if you call your class ADT_A01 it
will work correctly, which at least gives you a workaround. Both are
demonstrated in a unit test here:
https://hl7api.svn.sourceforge.net/svnroot/hl7api/trunk/hapi-mvn/hapi-test/src/test/java/ca/uhn/hl7v2/model/CustomModelClassTest.java
Cheers,
James
On Thu, Aug 16, 2012 at 2:42 PM, Michael Conner <mcon...@brookdaleliving.com
> wrote:
> FYI, I confirmed that by naming the class the same, but different package
> (e.g.: fo.bar.ADT_A01), and otherwise follow the custom model example:
> http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/CustomModelClasses.html,
> it all appears to work. Thanks!****
>
> ** **
>
> Also I did confirm what I think you would consider a bug with custom
> models and the INSURANCE and PROCEDURE groups. The issue is that it the
> ADT_A01. init() method does:****
>
> *private* *void* init(ModelClassFactory factory) {****
>
> *try* {****
>
> *this*.add(MSH.*class*, *true*, *false*);****
>
> *this*.add(SFT.*class*, *false*, *true*);****
>
> …****
>
> *this*.add(DRG.*class*, *false*, *false*);****
>
> *this*.add(ADT_A01_PROCEDURE.*class*, *false*, *
> true*);****
>
> *this*.add(GT1.*class*, *false*, *true*);****
>
> *this*.add(ADT_A01_INSURANCE.*class*, *false*, *
> true*);****
>
> *this*.add(ACC.*class*, *false*, *false*);****
>
> ..****
>
> ** **
>
> But then uses just INSURANCE and PROCEDURE when referencing:****
>
> *public* ADT_A01_INSURANCE getINSURANCE() { ****
>
> *return* getTyped("INSURANCE", ADT_A01_INSURANCE.*class*);****
>
> }****
>
> ** **
>
> It can do this because AbstractGroup.getName() strips off the group’s
> message’s name from the beginning of the name if it matches
> (“ADT_A01_INSURANCE” becomes “INSURANCE”). But this won’t be the case for
> a subtype of ADT_A01_ (e.g. as in the CustomModelClasses example, where it
> is ZDT_A01). So, for a ZDT_A01 that is a subtype of ADT_A01,
> ADT_A01_INSURANCE gets mapped to “ADT_A01_INSURANCE”, rather than
> “INSURANCE”. Subsequently a call to getINSURANCE(), which uses the short
> name, returns a null.****
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> *From:* Michael Conner
> *Sent:* Wednesday, August 15, 2012 11:37 AM
> *To:* 'James Agnew'
> *Cc:* hl7api-devel@lists.sourceforge.net
> *Subject:* RE: [HAPI-devel] Custom Segments immediately following a group*
> ***
>
> ** **
>
> Re: ambiguous. OK, that’s pretty much what I thought. ****
>
> ** **
>
> Re: Custom Model: I went down this path initially till I realized that it
> would be generating a different structure name (ZDT_A01). So, how would
> you do this and keep the name the same? Simply name the model class foo.bar.
> ADT_A01
> (same name, different package)?****
>
> ** **
>
> I have a work-around, which is to inject a fake, empty, segment before
> the segments using a regular expression. This seems to work, but is
> obviously a kludge.****
>
> ** **
>
> Also, I ran into a problem trying to do a ZDT_A01 following the custom
> model class example you mentioned. I don’t have the code anymore, but as I
> recall, the issue was that it was trying to use create an INSURANCE group,
> and it failed because there was not ZDT_A01_INSURANCE class. That is, it
> was doing a bit of reflection off the parent to figure out what the class
> should be. ****
>
> ** **
>
> *From:* jamesag...@gmail.com [mailto:jamesag...@gmail.com] *On Behalf Of
> *James
> Agnew
> *Sent:* Wednesday, August 15, 2012 11:11 AM
> *To:* Michael Conner
> *Cc:* hl7api-devel@lists.sourceforge.net
> *Subject:* Re: [HAPI-devel] Custom Segments immediately following a group*
> ***
>
> ** **
>
> Hi Michael,
>
>
> Unfortunately this is an area where the HL7 specification is ambiguous
> about how your message should be correctly parsed. HAPI generally errs on
> the side of putting unexpected segments closest in the structure to the
> segment immediately before it, which in your case sounds like it's not
> optimal.
>
> Probably the easiest way to solve this is to create a custom model class
> which extends ADT_A01 but adds your Z-segment. There is an example here:
> http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/CustomModelClasses.html
> .. which illustrates how to do this starting on line 59. The example
> creates a ZDT_A01, but you could just as easily actually create an ADT_A01.
>
> Given the ambiguity in the spec around this, it would certainly be nice if
> the parser provided a way of specifying a preferred behaviour for
> unexpected segments like this one. I've filed a bug to track the idea:
> https://sourceforge.net/tracker/?func=detail&aid=3557955&group_id=38899&atid=423838
>
> Cheers,
> James****
>
> On Wed, Aug 15, 2012 at 11:07 AM, Michael Conner <
> mcon...@brookdaleliving.com> wrote:****
>
> We’ve got a message where we want to have a custom segment at the end of
> an Patient Admit, ADT A01 message. We don’t have anything between IN1 and
> the custom segment. ****
>
> …****
>
> ****
>
> [{ --- INSURANCE begin ****
>
> * IN1 Insurance*****
>
> [ IN2 ] Insurance Additional Info.****
>
> [{ IN3 }] Insurance Additional Info - Cert****
>
> [{ ROL }] Role****
>
> }] --- INSURANCE end ****
>
> [ ACC ] Accident Information****
>
> [ UB1 ] Universal Bill Information****
>
> [ UB2 ] Universal Bill 92 Information****
>
> [ PDA ] Patient Death and Autopsy****
>
> *[ ZFA ] Financial Agreement*****
>
> * *****
>
> When HAPI parses the message, the ZFA ends up as a segment in the
> INSURANCE group, not the root of the message. Is there some way of changing
> this behavior? I’ve verified this with the HAPI test panel. Two other
> utilities that I’ve tried, MWB and Chameleon HL7 Messaging Toolkit, parse
> it differently, placing the Z segments at the root of the message, as
> desired, and not in an INSURANCE group.****
>
> ****
>
> * *****
>
> Here’s some sample data:****
>
> ****
>
>
> MSH|^~\&|DATASERVICES|CORPORATE|||20120711120510.2-0500||ADT^A01^ADT_A01|9c906177-dfca-4bbe-9abd-d8eb43df93a0|D|2.6
> ****
>
> EVN||20120701000000-0500****
>
>
> PID|1||397979797^^^SN^SN~4242^^^BKDMDM^PI~1000^^^YARDI^PI||Williams^Rory^H^^^^A||19641028000000-0600|M||||||||||31592^^^YARDI^AN
> ****
>
> NK1|1|Pond^Amelia^Q^^^^A|SPO|1234 Main
> St^^Sussex^WI^53089|^PRS^CP^^^^^^^^^555-1212||N****
>
> NK1|2|Smith^John^^^^^A~^The Doctor^^^^^A|FND|1234 S Water St^^New
> London^WI^54961||^WPN^PH^^^^^^^^^555-9999|C****
>
> PV1|2|I||R****
>
> GT1|1||Doe^John^A^^^^A||5678 Maple
> Ave^^Sussex^WI^53089|^PRS^PH^^^^^^^^^555-9999|||||OTH****
>
> IN1|1|CAP1000|YYDN|ACME
> HealthCare||||GR0000001|||||||HMO|||||||||||||||||||||PCY-0000042****
>
> IN1|2||||||||||||||Medicare|||||||||||||||||||||123-45-6789-A****
>
> IN1|3||||||||||||||Medicaid|||||||||||||||||||||987654321L****
>
> ZFA|6|31592|12345|YARDI|20120201000000-0600****
>
> ****
>
> ****
>
> ----------------------------------------- This email may contain
> confidential protected health information and/or attorney privileged
> information. If received in error, see our Privacy Statement at
> http://www.brookdaleliving.com/privacy-policy.aspx
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Hl7api-devel mailing list
> Hl7api-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel****
>
> ** **
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel