[4suite] Associating payments with charges...
Uche Ogbuji
uche at ogbuji.net
Fri Jul 25 15:30:35 MDT 2008
Marc wrote:
> First of all, I'd like to make sure I'm posting this in the right
> place... this is a fairly dumb question about Amara usage; am I in the
> right forum?
For Amara 1.x use the 4Suite mailing list:
http://lists.fourthought.com/mailman/listinfo/4suite
This mailing list is for the next generation of the projects.
[SNIP]
> My problem is that I can't see any way, in the original file, to
> associate the "creditpay" and "creditadj" records with the appropriate
> charges. They follow directly after, but they're not linked. So
> right now I'm ignoring them completely, and simply passing through the
> summary information from the charge record. This is not acceptable,
> however, as the patients will want to see payment details and dates...
Can you always rely on their coming immediately afterwards?
> Do I need to learn SAX to do this, or is there some nifty Bindery
> trick I can use?
Should be pretty easy using Bindery, as long as you know what patterns
to expect. If I'm getting the gist of your format here's what I would
personally do to keep it more in the Python world and less in the XML world:
* Use pushbind with "row" as the pattern. This will give an iterated
series of rows
* Iterate over row.xml_child_elements
* Use iterrools.groupby to group by the XPath pattern
child.xml_xpath(u"preceding-sibling::charge[1]")
** If you aren't comfy with itertools magic, you can just use a nested
for loop tracking the current charge element as you go through the children
You should now have everything conveniently grouped, and can proceed to
compute the aggregate output info.
> Also, the clearinghouse I'm sending this to apparently doesn't want
> "encoding=" in the header (although I suspect that it's not really a
> problem - there were so many other errors that their interpreter just
> barfed.) Just in case it is a problem, how can I suppress that so I
> only get
> "<?xml version="1.0"?>"
Their request is pretty counter to XML convention, so your only option
is raw text post-processing. You can omit the entire declaration, if
that works.
>> Do I need to learn SAX to do this, or is there some nifty Bindery
>> trick I can use?
>>
>
> A few hours later, I thought I'd clarify:
> 1) from my understanding of what SAX is and does, it sounds ideal for
> my purposes. I would iterate through "row"; when I receive a "charge"
> event I start building a "charge" record in my output; as I receive
> "creditpay" and "creditadj" events I create "payment" records in the
> output and append them to the ongoing "charge"; when I get another
> "charge" event, or hit the end of "row", I tie off the current
> "charge". Much the same as I would do if I were processing a flat
> text file, no?
>
You can do this in Amara using pushbind. You can also do it in plain
bindery. You shouldn't need SAX at all for what you want, and SAX is
truly a pain to deal with.
> 2) could that procedure be combined with the Domlette-style (don't
> know what else to call it) approach I've used for the rest of the file
> - in other words, can I pass in a chunk of previously-parsed XML, or
> would I need to use SAX from top to bottom?
>
pushbind is actually just like that: an iterator providing a series of
bindery chunks.
> 3) I've looked at the tenorsax example four or five times now and I'm
> still not sure I "get" it. It makes me feel like I'm playing Nethack
> - "Stop! You are not yet sufficiently experienced to adventure
> here!" I hate to ask, but could someone add just a few more comments
> to it, to make it clear to a SAX n00b like me just what it's doing at
> each step?
>
You shouldn't need Tenorsax. FWIW it will probably cease to exist in Akara.
--
Uche Ogbuji http://uche.ogbuji.net
Founding Partner, Zepheira http://zepheira.com
Linked-in profile: http://www.linkedin.com/in/ucheogbuji
Articles: http://uche.ogbuji.net/tech/publications/
More information about the 4suite
mailing list