Yes, isEmpty() has some issues. I think some of them were fixed,
unfortunately after the 2.1 release; but some corner cases like existing
but empty extra components were not considered. I'll look deeper into it as
soon as time permits.

Would you think, active nulls ("") should be considered an "empty" value?
Personally I don't think so....

Christian


2013/9/30 Ian Vowles <ian_vow...@health.qld.gov.au>

>  Checking for nulls, empty strings, empty data types and active nulls
> makes for a lot of code in message transforms.
>
> The presence of .isEmpty() looks like a godsend, but how is it intended to
> work?
>
> The following code produces the results shown below.  Is this the way it's
> supposed to work?
>
> Thanks
> Ian
>
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> package hapiexamples;
>
> import ca.uhn.hl7v2.HL7Exception;
> import ca.uhn.hl7v2.model.v231.message.ADT_A08;
>
> /**
>  *
>  * @author vowlesi
>  */
> public class CheckIsemptyFeatures {
>
>     private static final String ACTIVE_NULL = "\"\"";
>     private static ADT_A08 hl7In;
>
>     public static void main(String[] args) throws HL7Exception {
>         hl7In = new ADT_A08();
>         hl7In.getMSH().getMsh1_FieldSeparator().setValue("|");
>         hl7In.getMSH().getMsh2_EncodingCharacters().setValue("^~\\&");
>         System.out.println("After construction with new() .isEmpty()
> returns '" + hl7In.getPID().getPid19_SSNNumberPatient().isEmpty() + "'");
>         hl7In.getPID().getPid19_SSNNumberPatient().parse("");
>         System.out.println("After parsing '' (empty string) .isEmpty()
> returns '" + hl7In.getPID().getPid19_SSNNumberPatient().isEmpty() + "'");
>         hl7In.getPID().getPid19_SSNNumberPatient().parse("^^^^^");
>         System.out.println("After parsing '^^^^^' unexpected components
> .isEmpty() returns '" +
> hl7In.getPID().getPid19_SSNNumberPatient().isEmpty() + "'");
>         hl7In.getPID().getPid19_SSNNumberPatient().parse(ACTIVE_NULL);
>         System.out.println("After parsing '\"\"' (active null) .isEmpty()
> returns '" + hl7In.getPID().getPid19_SSNNumberPatient().isEmpty() + "'");
>         hl7In.getPID().getPid19_SSNNumberPatient().parse(ACTIVE_NULL +
> "^^^^");
>         System.out.println("After parsing '\"\"^^^^' (active null and
> unexpected components) .isEmpty() returns '" +
> hl7In.getPID().getPid19_SSNNumberPatient().isEmpty() + "'");
>         String inputHl7 =
> "MSH|^~\\&|HOMER|fake|DGATE-FAKE^prjHbcisRawIn|99999|20130923023038||ADT^A08|2013092302303834022003|P|2.3|||AL|AL|AUS|ASCII|ENG\r"
>                 + "EVN|A08|20130923023038|\r"
>                 + "PID|1|\"\"|708010^^^MRN^MR|PENSION
> NO^^^DSS^PE|SURNAME^GIVEN^^^MRS^^L||19381216|F||14|UNIT A/1 FAKE
> ST^\"\"^BRISBANE^^4000^\"\"^P||12345678^PRN^^^^^12345678||86^ENGLISH
> ONLY|W|2233|708010-4|4072469157||||1101||||||20130923|Y\r";
>         hl7In.parse(inputHl7);
>         System.out.println("After parsing message with medicare(SSN)
> .isEmpty() returns '" +
> hl7In.getPID().getPid19_SSNNumberPatient().isEmpty() + "'");
>         System.out.println("After parsing message with medicare(SSN)
> .getValue() returns '" +
> hl7In.getPID().getPid19_SSNNumberPatient().getValue() + "'");
>         System.out.println("After parsing message with language .isEmpty()
> returns '" + hl7In.getPID().getPid15_PrimaryLanguage().isEmpty() + "'");
>         System.out.println("After parsing message with language
> .getCe1_Identifier().getValue() returns '" +
> hl7In.getPID().getPid15_PrimaryLanguage().getCe1_Identifier().getValue() +
> "'");
>         inputHl7 =
> "MSH|^~\\&|HOMER|fake|DGATE-FAKE^prjHbcisRawIn|99999|20130923023038||ADT^A08|2013092302303834022003|P|2.3|||AL|AL|AUS|ASCII|ENG\r"
>                 + "EVN|A08|20130923023038|\r"
>                 + "PID|1|\"\"|708010^^^MRN^MR|PENSION
> NO^^^DSS^PE|SURNAME^GIVEN^^^MRS^^L||19381216|F||14|UNIT A/1 FAKE
> ST^\"\"^BRISBANE^^4000^\"\"^P||12345678^PRN^^^^^12345678||^^^^^|W|2233|708010-4|||||1101||||||20130923|Y\r";
>         hl7In.parse(inputHl7);
>         System.out.println("After parsing message without medicare(SSN)
> .isEmpty() returns '" +
> hl7In.getPID().getPid19_SSNNumberPatient().isEmpty() + "'");
>         System.out.println("After parsing message without medicare(SSN)
> .getValue() returns '" +
> hl7In.getPID().getPid19_SSNNumberPatient().getValue() + "'");
>         System.out.println("After parsing message without language
> .isEmpty() returns '" + hl7In.getPID().getPid15_PrimaryLanguage().isEmpty()
> + "'");
>         System.out.println("After parsing message without language
> .getCe1_Identifier().getValue() returns                  '" +
> hl7In.getPID().getPid15_PrimaryLanguage().getCe1_Identifier().getValue() +
> "'");
>         System.out.println("After parsing message without language
> .getCe2_Text().getValue() returns                        '" +
> hl7In.getPID().getPid15_PrimaryLanguage().getCe2_Text().getValue() + "'");
>         System.out.println("After parsing message without language
> .getCe3_NameOfCodingSystem().getValue() returns          '" +
> hl7In.getPID().getPid15_PrimaryLanguage().getCe3_NameOfCodingSystem().getValue()
> + "'");
>         System.out.println("After parsing message without language
> .getCe4_AlternateIdentifier().getValue() returns         '" +
> hl7In.getPID().getPid15_PrimaryLanguage().getCe4_AlternateIdentifier().getValue()
> + "'");
>         System.out.println("After parsing message without language
> .getCe5_AlternateText().getValue() returns               '" +
> hl7In.getPID().getPid15_PrimaryLanguage().getCe5_AlternateText().getValue()
> + "'");
>         System.out.println("After parsing message without language
> .getCe6_NameOfAlternateCodingSystem().getValue() returns '" +
> hl7In.getPID().getPid15_PrimaryLanguage().getCe6_NameOfAlternateCodingSystem().getValue()
> + "'");
>     }
> }
>
>
> After construction with new() .isEmpty() returns 'false'
> After parsing '' (empty string) .isEmpty() returns 'false'
> After parsing '^^^^^' unexpected components .isEmpty() returns 'true'
> After parsing '""' (active null) .isEmpty() returns 'false'
> After parsing '""^^^^' (active null and unexpected components) .isEmpty()
> returns 'false'
> After parsing message with medicare(SSN) .isEmpty() returns 'false'
> After parsing message with medicare(SSN) .getValue() returns '4072469157'
> After parsing message with language .isEmpty() returns 'false'
> After parsing message with language .getCe1_Identifier().getValue()
> returns '86'
> After parsing message without medicare(SSN) .isEmpty() returns 'false'
> After parsing message without medicare(SSN) .getValue() returns 'null'
> After parsing message without language .isEmpty() returns 'false'
> After parsing message without language .getCe1_Identifier().getValue()
> returns                  'null'
> After parsing message without language .getCe2_Text().getValue()
> returns                        'null'
> After parsing message without language
> .getCe3_NameOfCodingSystem().getValue() returns          'null'
> After parsing message without language
> .getCe4_AlternateIdentifier().getValue() returns         'null'
> After parsing message without language .getCe5_AlternateText().getValue()
> returns               'null'
> After parsing message without language
> .getCe6_NameOfAlternateCodingSystem().getValue() returns 'null'
>
>
> ********************************************************************************
>
> 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.
>
>
> **********************************************************************************
>
>
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
> _______________________________________________
> Hl7api-devel mailing list
> Hl7api-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>
>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to