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

Author: James Bull

Posted: 2011-12-31 at 15:51:00

I use SQLite.

Below are bizobjs; done using classdesigner, added datastructure as needed.

In both allergies and ptmeds(medication).

class AllergiesBizobj(dabo.biz.dBizobj):

def initProperties(self):

self.super()

self.Caption = "Allergies"

self.DataSource = "allergies"

self.KeyField = "pkid"

self.DataStructure = (

("pkid", "I", True, "allergies", "pkid"),

("ptid", "I", False, "allergies", "ptid"),

("allergywhat", "C", False, "allergies", "allergywhat"),

("allergydscrp", "C", False, "allergies", "allergydscrp"),

)

def afterInit(self):

self.DataSource = "allergies"

self.KeyField = "pkid"

self.LinkField="ptid"

self.addFrom("allergies")

self.addField("allergywhat")

self.addField("allergydscrp")

self.addField("pkid")

self.addField("ptid")

self.ParentLinkField="ptid"

self.FillLinkFromParent="True"

self.NewRecordOnNewParent="True"

class PtmedsBizobj(dabo.biz.dBizobj):

def afterInit(self):

self.DataSource = "ptmeds"

self.KeyField = "pkid"

self.addFrom("ptmeds")

self.addField("mednote")

self.addField("stop")

self.addField("medfreq")

self.addField("meds")

self.addField("meddose")

self.addField("start")

self.addField("pkid")

self.addField("ptid")

self.LinkField="ptid"

self.FillLinkFromParent="True"

self.NewRecordOnNewParent="True"

ptds is patient dataset

allergiesds = ptds.execute("""select d.ptid, d.fname,d.lname, allergies.allergywhat, allergies.pkid as allpkid, ptmeds.pkid as medpkid, ptmeds.meds

from dataset d

join allergies

on d.ptid = allergies.ptid

join ptmeds

on d.ptid = ptmeds.ptid""")

Thanks for any help you can offer. I suspect groups are what will be required but so far no luck in getting what I want.

Happy New Year from Australia

James

On 30/12/2011, at 2:21 AM, John Fabiani wrote:

> On Thursday, December 29, 2011 11:59:18 AM James Bull wrote:

>> Thanks, I have created the sql manually and although not an experienced user

>> of sql think I am on the right track. The UI displays exactly want I want

>> by using a number of grids to display the child tables of allergies and

>> medications; that was no effort at all given how user friendly dabo is.

>> Trying to produce a report containing that same information is what has me

>> confused right now. I am sure there is a simple solution which I cannot see

>> yet. regards

>> james

>>

> What database engine are you using? Post the SQL (along with the bizobj) for

> us to read and maybe we can help.

>

> If you have the SQL right then it is a matter of creating and using variables

> or just grouping in the report.

>

> Johnf

> _______________________________________________

> 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/10195755.yrl5iflvWh@linux-12

_______________________________________________

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/00C2F57E-037F-4CF2-BB62-381777068706@gmail.com

©2011 James Bull