|
From: Matt K. <mat...@in...> - 2006-07-24 21:51:03
|
I am able to disable all validation rules with the following code. What I
really wanted to do was to just disable the rule that validates phone
numbers, but I couldn't work out a way to reference the phone number
validation rule - I ended up just disabling them all.
PipeParser pipeParser = new PipeParser();
ValidationContextImpl context = (ValidationContextImpl)
pipeParser.getValidationContext();
List list = context.getPrimitiveRuleBindings();
Iterator it = list.iterator();
while (it.hasNext()) {
RuleBinding rb = (RuleBinding) it.next();
rb.setActive(false);
}
Message message = pipeParser.parse("the message");
Looks really similar to your code - but it definitely worked for me. If I
didn't have the rb.setActive(false) line in my code then a validation
exception would be thrown when my message was parsed.
-----Original Message-----
From: hl7...@li...
[mailto:hl7...@li...] On Behalf Of Scott
Arnold
Sent: Tuesday, 25 July 2006 1:44 AM
To: Scott Arnold; Bryan Tripp; Sarang Malwatkar
Cc: hl7...@li...; bry...@uh...; Manasse
Subject: Re: [HAPI-devel] HAPI Parser (v0.4.3) || Exception with blank Phone
Number in PID
To expand on this just a little *
I was specifically trying to figure out how I could disable the rule for the
DT data type, which is why I was messing just with the primitive rule
bindings.
I also tried disabling all rules by doing a:
parser.setValidationContext(new NoValidation());
Which again seemed to have no effect.
To test each scenario, after attempting to disable the rules, I would set a
DT value to something that would not pass the original validation, then
attempted to encode the message:
try {
a31.getINSURANCE(0).getIN1().getPlanEffectiveDate().setValue(" something
invalid");
String m = parser.encode(a31);
} catch (DataTypeException dte) {
System.out.println("Still get DataTypeException...");
dte.printStackTrace();
}
>>> "Scott Arnold" <sa...@bj...> 7/24/2006 10:23:22 AM >>>
Did anyone ever figure out how exactly to disable some or all of a
parser's validation? I did some experimentation myself using the
following code:
PipeParser parser = new PipeParser();
ValidationContextImpl vc = (ValidationContextImpl)
parser.getValidationContext();
List rulebindings = vc.getPrimitiveRuleBindings();
for (Iterator iter = rulebindings.iterator(); iter.hasNext();) {
RuleBinding rb = (RuleBinding) iter.next();
// I individually tried the following three means for disabling
validation on a rule:
// rb.setActive(false);
// iter.remove();
// rb = null;
}
// Also tried this (thinking maybe it would disable them all):
// parser.setValidationContext(null);
None of the means I tried had any affect. I'm still not sure what the
proper way of modifying or disabling a rule is.
Scott Arnold
BJC HealthCare
>>> "Bryan Tripp" <bp...@gm...> 1/26/2006 3:10:40 PM >>>
Hi Sarang,
The default behaviour is to validate against the HL7 telephone number
format (the string "() - " doesn't conform to this), but you can
configure all the validation rules that are used by a Parser. If you
want to do a lot of configuration you should construct your Parser
with a custom ca.uhn.hl7v2.validation.ValidationContext. But in this
case it's probably simplest to do this ...
ValidationContextImpl context =
(ValidationContextImpl)parser.getValidationContext();
List list = context.getPrimitiveRuleBindings();
... then dig through the list and replace the TN binding with
something that allows whatever you want to allow.
Bryan
On 1/26/06, Sarang Malwatkar <sma...@im...> wrote:
> Hi,
>
> We are getting a DataTypeException
> when parsing an ADT message,
> which contains a blank Phone Number in PID segment.
>
> The Phone Number actually contains
> empty brackets with spaces: "|( ) - |"
>
> Exception Details (in PipeParser):
> Error while parsing: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 #14.
>
> Can't the HAPI Parser handle empty Phone Numbers ?
>
> The problem is that, the parser returns a 'null' Message Object.
> So we loose all the other valid fields also.
>
> Is there any solution to this ?
>
> We have tried both v0.4.3 as well as v0.5beta
>
>
> Thanks,
> -Sarang Malwatkar.
> Sr. Project Manager,
> iMedX Information Services,
> sma...@im...
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through
log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD
SPLUNK!
>
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Hl7api-devel mailing list
> Hl7...@li...
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD
SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Hl7api-devel mailing list
Hl7...@li...
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
Hl7...@li...
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
Hl7...@li...
https://lists.sourceforge.net/lists/listinfo/hl7api-devel
|