Hl7- hapi - PID-5.7.2 value - hl7

I use hapi java library to parse HL7 file.
I need to access pid-5.7.2 value (=titi):
PID|1||1^^^^||toto^test^^^MME^^L~titi^test^^^MME^^D
I can access pid-5.7 value (=L)
pidPatient.getPatientName()[0].getXpn7_NameTypeCode().getValue());
But how can i get 5.7.2 value ?

This is not PID-5-7-2, this is the second repetition of the whole PID-5 segment. ~ is the default repetition symbol in HL7.
My HAPI skills are a bit rusty, but I'd suggest trying something like this to get to the field, where "titi" is. Note the array index 1.
pidPatient.getPatientName()[1].getXpn1_FamilyName().getValue());

Related

How do I reverse tostring(table) in Lua

In Lua when you use the method tostring(table) it returns something like this: table: 0xb5b1f0. So I was wondering if there is any way of reversing this and turning it back into the regular table.
This actually prints the pointer to the table data as a hex integer. You cannot use the numeric value of a pointer in Lua to access the data directly (in a standard way).
If you are really interested, you can serialize (convert a table to a string) (recursively), and then back into a table, but that is much less convenient than an 8 digit hex. If you are using any framework or library, there is a good chance that it comes with a built-in table serialization function. If not, then just look up "lua table serialization function" on any search engine. (I'll find a good function and write it here)
Something else you might want to know, is that you can do something like this with functions: string.dump will dump the Lua binary for the function in a Lua string, and can then later be converted to a function using loadstring().

Find clang::Type in Clang AST by name

In Clang AST, is it possible to find type by name?
For example I have qualified name : nspace::my_type<int, 10u>. How can I check if type is present in current translation unit?
NOTE: my knowledge is extremely limited from just once writing a clang tidy check to do some update I needed. Might be wrong.
There are two possible things that you might need in clang AST depending on the task at hand: Type and TypeLocation. I needed the type location, so this is what I'll mention first.
Find the type spelling.
In this case what you actually want is the TypeLocation ast nodes. They represent a spelling of a type.
Unfortunately are not printed by clang-query.
The way to search for them is by using a type_loc matcher.
This is from something I needed: find all specialisations of a wide template.
This would find me all the spellings of wide<T>
l isWide hasDeclaration(classTemplateDecl(namedDecl(hasName("wide"))))
l isWideSpec templateSpecializationType(isWide)
l wideLoc typeLoc(loc(isWideSpec))
wideLoc - is what I was using to change the spelling of the type.
Different type_loc have parents that are also type_loc.
So for example I can find all entries of T unless they are inside wide<T>
typeLoc(loc(asString("T")), unless(hasAncestor(wideLoc)))
Find all of the actual usages of the type, regardless of how it is spelled.
Now for this type of problem you'd need to match on a type.
Have never done this myself, but we can see abseil doing this for example here:
https://github.com/llvm/llvm-project/blob/b426b45d101740a21610205ec80610c6d0969966/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp#L36
PS. Just in case - all clang ast matchers:
https://clang.llvm.org/docs/LibASTMatchersReference.html

Parse email without Tmail

How would you parse an email without using using a library like TMail that does parsing for you using Ruby on Rails?
Since this is for an assignment I will answer with some resources that outline the format email should take:
There have been several email specifications
https://www.rfc-editor.org/rfc/rfc822 - Outlines the first version (in 1982)
https://www.rfc-editor.org/rfc/rfc2822 - Updated this (2001)
https://www.rfc-editor.org/rfc/rfc5322 - Was the latest update (2008)
Depending on how much you actually need to implement I would suggest starting with the first as it was the simplest. These outline the patterns and format that the message will be in.
To start with you will find the headers then two carriage returns followed by the message body. There are a couple of options here. It's quite possible to start with regular expressions or even just pattern matching but it may be worth looking into Parsing Expression Grammars in more detail (treetop for example).
I hope this gets you started.

Nesting Jasper expressions

I have a field ($P{ORDER}.permit) which is Integer (0,1) and I'd like to display it as a String ("No", "Yes"). So I added below keys to ResourceBoundle:
order.permit.0=No
order.permit.1=Yes
I wrote expression $R{order.permit.$P{ORDER}.permit} but it doesn't work. An exception is thrown
net.sf.jasperreports.engine.JRException: Too many groovy classes were
generated. Please make sure that you don't use Groovy features such as
closures that are not supported by this report compiler.
I suspect that this exception is caused by nesting jasper expressions or nesting them in wrong way.
How should I write the expression to achieve desired result?
EDIT: str("order.permit." + $P{ORDER}.permit) is the answer. Details in the below post.
Use str() instead of $R{}.
See also http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=54665:
$R{} and str() are largely the same thing. The functional difference
is that $R{} can only be used with fixed/static keys, while str() can
be used with dynamic message keys, e.g. str("message.prefix." +
$P{message}).

SnakeYAML: How to disable underscore stripping when parsing?

Here's my problem. I have YAML doc that contains the following pair:
run_ID: 2010_03_31_101
When this get's parsed at
org.yaml.snakeyaml.constructor.SafeConstructor.ConstructYamlInt:159
underscores get stripped and Constructor returns Long 20100331101
instead of unmodified String "2010_03_31_101" that I really need.
QUESTION: How
can I disable this behavior and force parser to use String constructor
instead of Long?
OK. Got answer form their mailing list. Here it is
Hi, according to the spec
(http://yaml.org/type/int.html): Any
“_” characters in the number are
ignored, allowing a readable
representation of large values
You have a few ways to solve it. 1) do
not rely on implicit types, use quotes
(single or double) run_ID:
'2010_03_31_101'
2) Turn off resolver for integers (as
it is done here for floats) link
1 link 2
3) Define your own pattern for int
link 3
Please be aware that when you start to
deviate from the spec other recipients
may fail to parse your YAML document.
Using quotes is safe.
Andrey

Resources