In the current transformation I am working on I thought I would try using the 
ADT_AXX superstructure, since multiple ADT types need to be handled.
Some complexity was present, given that the inbound has several Z-Segments, 
which I have built definitions for, and the outbound has one of a different 
structure to the inbounds.

Snippets from the code dealing with them are shown below. The hl7In mentioned 
is of ADT_AXX type.

        ADT_AXX hl7Out = new ADT_AXX();
        hl7Out.setValidationContext(new NoValidation());
        ZPX zpxIn = new ZPX(hl7In.getParent(), hl7In.getModelClassFactory());
        ZVX zvxIn = new ZVX(hl7In.getParent(), hl7In.getModelClassFactory());
        GenericSegment zSeg;
        try {
            zSeg = (GenericSegment) hl7In.getINSURANCE().get("ZPX");
            zpxIn.parse(zSeg.encode());
        } catch (HL7Exception ex) {
            // Problem finding zpx leave it empty
        }
        try {
            zSeg = (GenericSegment) hl7In.getINSURANCE().get("ZVX");
            zvxIn.parse(zSeg.encode());
        } catch (HL7Exception ex) {
            // Problem finding zvx, leave it empty
        }

        hl7Out.addNonstandardSegment("ZPD");
        GenericSegment zpdGen = (GenericSegment) hl7Out.get("ZPD");
        ZpdEdis zpdOut = new ZpdEdis(hl7Out.getParent(), 
hl7Out.getModelClassFactory());
        SegmentTranslation.processZpd(zpxIn, hl7In.getPV1(), zvxIn, zpdOut);
        zpdGen.parse(zpdOut.encode());

All of this works very nicely, and all was proceeding through test cases for 
different message types with me reviewing the content of a .printstructure().
I got a nasty surprise when I finally came to .encode() the result:

java.lang.NullPointerException
        at 
java.util.Collections$UnmodifiableCollection.<init>(Collections.java:994)
        at java.util.Collections$UnmodifiableSet.<init>(Collections.java:1066)
        at java.util.Collections.unmodifiableSet(Collections.java:1056)
        at 
ca.uhn.hl7v2.model.AbstractSuperMessage.getStructuresWhichChildAppliesTo(AbstractSuperMessage.java:78)
        at 
ca.uhn.hl7v2.validation.builder.support.OnlyAllowableSegmentsInSuperstructureRule.checkStructure(OnlyAllowableSegmentsInSuperstructureRule.java:71)
        at 
ca.uhn.hl7v2.validation.builder.support.OnlyAllowableSegmentsInSuperstructureRule.apply(OnlyAllowableSegmentsInSuperstructureRule.java:55)
        at 
ca.uhn.hl7v2.validation.builder.support.OnlyAllowableSegmentsInSuperstructureRule.apply(OnlyAllowableSegmentsInSuperstructureRule.java:46)
        at 
ca.uhn.hl7v2.validation.AbstractValidator.testMessageRules(AbstractValidator.java:98)
        at 
ca.uhn.hl7v2.validation.AbstractValidator.validate(AbstractValidator.java:82)
        at ca.uhn.hl7v2.parser.Parser.assertMessageValidates(Parser.java:611)
        at ca.uhn.hl7v2.parser.Parser.encode(Parser.java:275)
        at ca.uhn.hl7v2.parser.PipeParser.encode(PipeParser.java:1003)
        at ca.uhn.hl7v2.model.AbstractMessage.encode(AbstractMessage.java:207)
        at 
au.gov.qld.health.sit.transform.hl7.HbcisNormAdtTxEdisTest.testTransformA01(HbcisNormAdtTxEdisTest.java:81)

Doing a .setValidationContext(new NoVAlidation) on the result message does not 
prevent the error. 

Is there anything I can do to enable this result to .encode()?  The 
prinstructure() shows everything exactly as I want it.

Thanks
Ian

********************************************************************************
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.
**********************************************************************************


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to