[Gambas-user] Subsetting a collection & clipboarding

Werner wdahn at ...1000...
Sun Oct 31 11:32:53 CET 2010


On 31/10/10 16:42, Bruce Bruen wrote:
> Hi folks,
>
> I have a class "A" that has as one of its' properties ,"b", a collection of 
> objects (of type "C").  I wish to 
> a) provide a (READ) property in A that returns a subset of the collection (b') 
> based on a parameter (relating to a known property of C, say something like 
> "DaysAgo is less than 45" where DaysAgo is a property of C), and
> b) copy all attributes of each instance of C in b' onto a new clipboard item.
>
> To confound the issue, the DaysAgo property of C is computed and is relative 
> to another date that is independent of both A and C.  Or to put that another 
> way, I suppose I need a window function, rather than a subsetting function 
> that will return each instance of C in b that is between a basedate and a 
> number of days beforehand.
>
> To try and put this into a better perspective, we have a patient "Ms Sally 
> Simpson" who was diagnosed in early August as suffering from infectious 
> mononucleosis (aka glandular fever, college disease, kissing disease etc etc).  
> She has had a series of pathology tests done over the last 6 months when she 
> first presented ("Doctor, I dont feel well").  The blood samples take from her 
> over this period may have been subjected to over 150 odd pathology tests.  My 
> learned pathological statisticians ( sorry pathology statisticians) now want 
> to select specific examples of certain tests to see if there is any evidence 
> of atypical results being "ahem, missed" in the earlier tests.
>
> So, class A(patient) (instance "Simpson, Sally") has a collection b of path 
> tests generalised as a "test" (C) (with many specialisations).  The 
> requirement put to me is "I want to copy all the data for the IG Count tests 
> done on Sally in the period between 2 Aug and 45 days prior to the clipboard 
> (so I can paste them into a spreadsheet and do mystical incantations over 
> them)"
>
> (OK, I added the last bit.)
>
> To me this requires subsetting b over testtype between two parameters (day0 
> and daysago)
>
> So, is there a way to provide a "parameterised" property accessor, 
> TestSeries_Read(ttype as TestTypeCode, startdate as Date, window as Integer) 
> as TestSeries
> and when I get it, how do I copy all attributes of each instance in the subset 
> to the clipboard (i.e. how can I serialise a specialisation of a generic 
> type).
>
> If you have read this far, thank you.
> If you can provide some help, may you be blessed.
>   

I don't think there is any reason why you can't write in your class:

Function TestSeries_Read(patient_id as Integer, ttype as TestTypeCode,
startdate as Date, window as Integer) AS String[]

... do your magic here

End

However, obviously your data must be persistent so this shouts loudly:
DATABASE!
Apart from persistence it also makes it easier to retrieve the
measurements for a patient over a time range and/or test type.

You can then slap the retrieved data into a component designed for that
purpose. These are documented here:
http://gambasdoc.org/help/comp/gb.db.form

Propably you would want to use a DataView.

The user can then play with it (ie "show me when Bilirubin was highest")
or copy from the DataView into the Clipboard.

------------------

A few more thoughts:
What you don't mention is how the measurements are supposed to become
available to your application. Manual entry?
If this is an application for clinical medicine (non research) and you
expect a lot of data over time which needs to be archived properly it
might be worthwhile to take a closer look at the DICOM standard.

Just my 0.02 HK$.

Regards
Werner






More information about the User mailing list