Non-standard segments of a message are not shown

View: New views
5 Messages — Rating Filter:   Alert me  

Non-standard segments of a message are not shown

by biliboc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Dear All,

I am pretty new in HAPI and I have this question:
Why do non-standard segments of a message are not shown?
Or, am I doing something wrong?

For instance, I added FHS segment to a DFT_P03 (like in the code sequence below) but when displayed I get this output (no FHS segment at all):

<DFT_P03 xmlns="urn:hl7-org:v2xml">
    <MSH>
        <MSH.1>|</MSH.1>
        <MSH.2>^~\&amp;</MSH.2>
        <MSH.3>
            <HD.1>CHARGER</HD.1>
        </MSH.3>
        <MSH.5>
            <HD.1>IDX_TES_CHG</HD.1>
        </MSH.5>
        <MSH.7>
            <TS.1>200702161541</TS.1>
        </MSH.7>
        <MSH.9>
            <MSG.1>DFT^P03</MSG.1>
        </MSH.9>
        <MSH.11>
            <PT.1>P^T</PT.1>
        </MSH.11>
        <MSH.12>
            <VID.1>2.4</VID.1>
        </MSH.12>
        <MSH.18>ASCII</MSH.18>
    </MSH>
    <EVN>
        <EVN.1>DFT_P03</EVN.1>
        <EVN.6>
            <TS.1>200702161541</TS.1>
        </EVN.6>
    </EVN>
</DFT_P03>

The code:

        ca.uhn.hl7v2.model.v24.message.DFT_P03 p03 = new DFT_P03();

        MSH msh = p03.getMSH();
        ((AbstractPrimitive)msh.getSendingApplication().getComponent(0) ).setValue( "CHARGER" );
        ((AbstractPrimitive)msh.getReceivingApplication().getComponent(0) ).setValue( "IDX_TES_CHG" );
        msh.getDateTimeOfMessage().getTimeOfAnEvent().setValue( TransformUtils.SDFD_YYYYMMDDHHMM.format( new Date() ) );
        msh.getFieldSeparator().setValue( "|" );
        msh.getEncodingCharacters().setValue( "^~\\&" );
        ((AbstractPrimitive)msh.getVersionID().getComponent(0) ).setValue( "2.4" );
        ((AbstractPrimitive)msh.getProcessingID().getComponent(0) ).setValue( "P^T" );
        msh.getMessageType().getMessageType().setValue( "DFT^P03" );
        msh.getCharacterSet(0).setValue("ASCII");

        EVN evn = p03.getEVN();
        evn.getEventTypeCode().setValue( "DFT_P03" );
        ((AbstractPrimitive)evn.getEventOccurred().getComponent(0) ).setValue( TransformUtils.SDFD_YYYYMMDDHHMM.format( new Date() ) );

        p03.addNonstandardSegment("FHS");
        FHS fhs = new FHS(p03, new DefaultModelClassFactory());
        fhs.getFileFieldSeparator().setValue( "|" );
        fhs.getFileEncodingCharacters().setValue("^~\\&");
        fhs.getFileSendingApplication().setValue("CHARGER");
        fhs.getFileReceivingApplication().setValue("IDX_TES_CHG");
        ((AbstractPrimitive)fhs.getFileCreationDateTime().getComponent(0) ).setValue( TransformUtils.SDFD_YYYYMMDDHHMM.format( new Date() ) );

        p03.addNonstandardSegment("FTS");
        FTS fts = new FTS(p03, new DefaultModelClassFactory());
        fts.getFileBatchCount().setValue("0");
        fts.getFileTrailerComment().setValue( "URA" );

        //instantiate an XML parser
        XMLParser xmlParser = new DefaultXMLParser();
        System.out.println(xmlParser.encode(p03));






Thanks,
Constantin Mitocaru

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Re: Non-standard segments of a message are not shown

by James Agnew-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Constantin,

The only thing you need to change is to retrieve the nonstandard segment
from the message after you have added it instead of instantiating a new
one, as the message itself takes care of instantiating the new segment.

Basically, replace this line:
FHS fhs = new FHS(p03, new DefaultModelClassFactory());

With this one:
FHS fhs = (FHS) p03.get("FHS");

Hope this helps!

By the way, would you mind if I used your example code in the "HAPI By
Examples" section of the website I am working on?

James Agnew


Constantin Mitocaru wrote:

>
>
> Dear All,
>
> I am pretty new in HAPI and I have this question:
> Why do non-standard segments of a message are not shown?
> Or, am I doing something wrong?
>
> For instance, I added FHS segment to a DFT_P03 (like in the code
> sequence below) but when displayed I get this output (no FHS segment
> at all):
>
> <DFT_P03 xmlns="urn:hl7-org:v2xml">
>     <MSH>
>         <MSH.1>|</MSH.1>
>         <MSH.2>^~\&</MSH.2>
>         <MSH.3>
>             <HD.1>CHARGER</HD.1>
>         </MSH.3>
>         <MSH.5>
>             <HD.1>IDX_TES_CHG</HD.1>
>         </MSH.5>
>         <MSH.7>
>             <TS.1>200702161541</TS.1>
>         </MSH.7>
>         <MSH.9>
>             <MSG.1>DFT^P03</MSG.1>
>         </MSH.9>
>         <MSH.11>
>             <PT.1>P^T</PT.1>
>         </MSH.11>
>         <MSH.12>
>             <VID.1>2.4</VID.1>
>         </MSH.12>
>         <MSH.18>ASCII</MSH.18>
>     </MSH>
>     <EVN>
>         <EVN.1>DFT_P03</EVN.1>
>         <EVN.6>
>             <TS.1>200702161541</TS.1>
>         </EVN.6>
>     </EVN>
> </DFT_P03>
>
> The code:
>
>         ca.uhn.hl7v2.model.v24.message.DFT_P03 p03 = new DFT_P03();
>
>         MSH msh = p03.getMSH();
>        
> ((AbstractPrimitive)msh.getSendingApplication().getComponent(0)
> ).setValue( "CHARGER" );
>        
> ((AbstractPrimitive)msh.getReceivingApplication().getComponent(0)
> ).setValue( "IDX_TES_CHG" );
>         msh.getDateTimeOfMessage().getTimeOfAnEvent().setValue(
> TransformUtils.SDFD_YYYYMMDDHHMM.format( new Date() ) );
>         msh.getFieldSeparator().setValue( "|" );
>         msh.getEncodingCharacters().setValue( "^~\\&" );
>         ((AbstractPrimitive)msh.getVersionID().getComponent(0)
> ).setValue( "2.4" );
>         ((AbstractPrimitive)msh.getProcessingID().getComponent(0)
> ).setValue( "P^T" );
>         msh.getMessageType().getMessageType().setValue( "DFT^P03" );
>         msh.getCharacterSet(0).setValue("ASCII");
>
>         EVN evn = p03.getEVN();
>         evn.getEventTypeCode().setValue( "DFT_P03" );
>         ((AbstractPrimitive)evn.getEventOccurred().getComponent(0)
> ).setValue( TransformUtils.SDFD_YYYYMMDDHHMM.format( new Date() ) );
>
>         p03.addNonstandardSegment("FHS");
>         FHS fhs = new FHS(p03, new DefaultModelClassFactory());
>         fhs.getFileFieldSeparator().setValue( "|" );
>         fhs.getFileEncodingCharacters().setValue("^~\\&");
>         fhs.getFileSendingApplication().setValue("CHARGER");
>         fhs.getFileReceivingApplication().setValue("IDX_TES_CHG");
>        
> ((AbstractPrimitive)fhs.getFileCreationDateTime().getComponent(0)
> ).setValue( TransformUtils.SDFD_YYYYMMDDHHMM.format( new Date() ) );
>
>         p03.addNonstandardSegment("FTS");
>         FTS fts = new FTS(p03, new DefaultModelClassFactory());
>         fts.getFileBatchCount().setValue("0");
>         fts.getFileTrailerComment().setValue( "URA" );
>
>         //instantiate an XML parser
>         XMLParser xmlParser = new DefaultXMLParser();
>         System.out.println(xmlParser.encode(p03));
>
>
>
>
>
>
> Thanks,
> Constantin Mitocaru
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Hl7api-devel mailing list
> Hl7api-devel@...
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>  


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

How to deactivate telephone field validation PID.13 ?

by biliboc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Dear all,

I want to deactivate telephone field validation when using
PipeParser.parse() method.
I'm getting the following error:

ca.uhn.hl7v2.model.DataTypeException: Failed validation rule: Matches
the regular expression (\d{1,2}
)?(\(\d{3}\))?\d{3}-\d{4}(X\d{1,5})?(B\d{1,5})?(C.*)?: Segment: PID (rep
0) Field #13
    at
ca.uhn.hl7v2.model.AbstractPrimitive.setValue(AbstractPrimitive.java:84)
    at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:359)
    at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:308)
    at ca.uhn.hl7v2.parser.PipeParser.doParse(PipeParser.java:258)
    at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:151)
    at ca.uhn.hl7v2.app.Responder.processMessage(Responder.java:139)
    at ca.uhn.hl7v2.app.Receiver$Grunt.run(Receiver.java:121)

Regards,
Constantin


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Re: How to deactivate telephone field validation PID.13 ?

by Bryan Tripp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Constantin,

You can change the validation rules using
Parser.setValidationContext(). You will have to provide your own
validation.ValidationContext implementation with the rules you want.
See validation.impl.DefaultValidation for the defaults.

Bryan

On 3/12/07, Constantin Mitocaru <constantin.mitocaru@...> wrote:

>
>
> Dear all,
>
> I want to deactivate telephone field validation when using
> PipeParser.parse() method.
> I'm getting the following error:
>
> ca.uhn.hl7v2.model.DataTypeException: Failed validation rule: Matches
> the regular expression (\d{1,2}
> )?(\(\d{3}\))?\d{3}-\d{4}(X\d{1,5})?(B\d{1,5})?(C.*)?: Segment: PID (rep
> 0) Field #13
>    at
> ca.uhn.hl7v2.model.AbstractPrimitive.setValue(AbstractPrimitive.java:84)
>    at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:359)
>    at ca.uhn.hl7v2.parser.PipeParser.parse(PipeParser.java:308)
>    at ca.uhn.hl7v2.parser.PipeParser.doParse(PipeParser.java:258)
>    at ca.uhn.hl7v2.parser.Parser.parse(Parser.java:151)
>    at ca.uhn.hl7v2.app.Responder.processMessage(Responder.java:139)
>    at ca.uhn.hl7v2.app.Receiver$Grunt.run(Receiver.java:121)
>
> Regards,
> Constantin
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Hl7api-devel mailing list
> Hl7api-devel@...
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Re: Non-standard segments of a message are not shown

by Hady Lattouf :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi James,

I am using a MFN_M01 message, my code is something like this:

MFN_M01 mf = new MFN_M01();
mf.getMSH().getFieldSeparator().setValue("|");
mf.getMSH().getEncodingCharacters().setValue("^~\\&");
...
mf.addNonstandardSegment("ZBN");
ZBN zbn = (ZBN) mf.get("ZBN");
zbn.getLocation().setValue("xxxxxxxxxxxxxxx");

I am getting the following exception though:
java.lang.ClassCastException: ca.uhn.hl7v2.model.GenericSegment

my ZBN class extends AbstractSegment (later I tried to change it to extends GenericSegment but both failed)

I am using v23.

Thanks,