Re: [dabo-users] Reports - one to many

Author: Paul McNett

Posted: 2011-12-29 at 14:56:51

On 12/28/11 4:10 PM, James Bull wrote:

> Wondering if I could get some pointers.

I will try!

> I have tables setup as

> Parent(person)

> -ChildA(many: medications)

> -ChildB(many: allergies)

Pretty standard.

> The report I am trying to produce aims to have Parent details then below this 2 lists of childA and childB - to provide a summary report of medication one may be on and allergies.

You need to group on the parent's id, and put the "detail" of that parent in the

group header for that group. Here's an example group definition (in rfxml format

which you could carefully copy/paste into the <Groups> section of your report's

.rfxml file)

<Group>

<expr>self.Record.patient_id</expr>

<ResetPageNumber>True</ResetPageNumber>

<startOnNewPage>True</startOnNewPage>

<Objects>

<GroupHeader>

<!-- once group defined, open designer

and add detail here. -->

</GroupHeader>

<GroupFooter>

</GroupFooter>

</Objects>

</Group>

You'll also need groups for the allergies and medications children, and to put their

detail in their group headers. Leave the detail band empty. Here's a starting example

for the allergy group:

<Group>

<expr>(self.patient_id, self.allergy_id</expr>

<ResetPageNumber>False</ResetPageNumber>

<startOnNewPage>False</startOnNewPage>

<Objects>

<GroupHeader>

<!-- once group defined, open designer

and add detail here. -->

</GroupHeader>

<GroupFooter>

</GroupFooter>

</Objects>

</Group>

> My problem is as I understand it, reportwriter needs denormalized dataset - which to me means each 'row' contains all the same data with one unique element; so in the example dataset below the first 3 'rows' are unique on meds(and medpkid) and retain same allergy etc:

You don't actually need to fill the dataset with all repeated data, but that is the

safest way. The reportwriter will need data for relevant fields while it processes

the "records".

>

> ( {'meds': 'medication-test1', 'pkid': 21, 'allergy': 'penicillin-test', 'medid': 465, 'ptid': 465, 'medpkid': 217},

> {'meds': 'medication-test2', 'pkid': 21, 'allergy': 'penicillin-test', 'medid': 465, 'ptid': 465, 'medpkid': 471},

> {'meds': 'drug-test', 'pkid': 21, 'allergy': 'penicillin-test', 'medid': 465, 'ptid': 465, 'medpkid': 472}, {'meds': 'medication-test1', 'pkid': 240, 'allergy': 'sulphur-test', 'medid': 465, 'ptid': 465, 'medpkid': 217},

> {'meds': 'medication-test2', 'pkid': 240, 'allergy': 'sulphur-test', 'medid': 465, 'ptid': 465, 'medpkid': 471},

> {'meds': 'drug-test', 'pkid': 240, 'allergy': 'sulphur-test', 'medid': 465, 'ptid': 465, 'medpkid': 472} )

Sorry, I didn't look at your dataset when composing my reply, but it looks like you

have all the needed data to make your initial report.

>

> So in report I am trying to list for each unique person(ptid) a list allergies: pencillin,sulphur and list meds: medication-test1 etc, instead as the rw Cursor iterates over each element in tuple I have long list of allergies essentially repeated in current example for each unique medication.

>

> Have tried grouping but still cannot achieve what I envisage.

> What am I doing wrong? Any help would be most appreciated.

Please let me know if I'm on the right track in helping you, after you've tried the

grouping like what I've described.

By the way, I do have it on my list to enhance the report writer to allow the Cursor

to be a bizobj, and the reportwriter could then figure out how to iterate the bizobj

and the children. But it is a much simpler implementation how it is.

Paul

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/4EFCC603.8040600@ulmcnett.com

©2011 Paul McNett