If you are ok that your selection widget contains uncomplete
information, than you are right. But what I am telling about, is that
you give the user a selector with unique drug names at first:

db().select(db.drugs.name, distinct=True)

user selects 'Amoxycilin', you make another query:

Amoxycilines = db(db.drugs.name.like('Amoxycilin')).select()

and than if you want to offer google's 'I am feeling lucky' approach
you just give the user Amoxycilines[0],
and if you want the user to choose from variety, you print all
Amoxycilines to selector widget.

'I am feeling lucky' approach that works without much overhead:

an_Amoxycilin = db(db.drugs.name.like('Amoxycilin')).select(limitby=
(0,1))

On Jun 2, 11:10 am, Horst Herb <my.list.subscripti...@gmail.com>
wrote:
> On Tue, Jun 2, 2009 at 4:48 PM, SergeyPo <ser...@zarealye.com> wrote:
>
> > This works for sure in sqlite, mysql and oracle:
>
> > db().select(db.tablename.fieldname, distinct=True)
>
> > and this is correct approach because I can not imagine biz logic when
> > you want to select distinct values AND their ID's etc. fields. You
> > normally use select distinct when you need a list of available values
> > in a field.
>
> practical example from my own web app:
> A doctor prescribes medication. He can select it from a pharmaceutical 
> database.
> He can select the drug by generic or brand name.
> Each drug comes in a variety of forms, strengths, packet sizes etc.
> plus some incur health system subsidies, some barnd price premiums
> etc.
>
> In most instances, I am not interested whatsoever in 20 manufacturers
> producing the same product and it coming in a variety of packet sizes
> - all I want is Amoxycilin trihydrate tablets 500mg (and not a hundred
> variations thereof cluttering my selection widget). There are some
> 60,000 drug product entries in the larger drug database - and less
> than 2000 unique drugs
>
> But, in order to call up product information and to check allergies
> and interactions - I need the id of the drug.
>
> Just one of a great many practical examples.
>
> Horst
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to