Thanks for showing me how the db would be constructed in web2py.
My big question is  how do I code to display the patient in dropdown
menu on a web page.
The user would select a patient and then all the prescriptions for the
patient would be displayed on the web page.
I could code in Django the view and  the template.I could get it to
display the dropdown list of patients, but when I clicked the patient
I could see the correct id  value  although I crashed the program,
Of course I am not a Django expert, nor a Grails expert

Is there a place where I could access the source code for the
tutorials  such as Cookbook. I am running into a lot of syntax  errors
with keying in the examples. I get bogged down debugging errors. Is
there a book, ebook?
Thanks for the time you have spent with me!
Jim



On Jun 27, 11:03 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Short answer:
>     yes it is possible to read that Django model and read those data
> directly from the existing sqlite database.
>     If you really want to I can send you instructions on how to do it
> or can arrange to do the conversion from you.
>
> Long answer:
>     Don't. Export the data for example in CSV and re import them in
> web2py in a better model.
>     Example:
> 1) Why patients have web pages and not email but doctors have emails
> but not web pages not middle names?
> 2) What if two doctors have the same name?
> 3) What if a Doctor is also a Patient of another doctor?
> 4) Doctors and Patients should be derived from the same class
> (auth_user) and belong to groups with different permissions (Patients,
> Doctors).
> 5) Pills (prescriptions) should not be associated to multiple doctors
> (Many2Many) but always by a single doctor (One2Many)
> 6) The reason for the Pills (prescription) should probably be a text
> field and perhaps should allow attachments (like lab reports etc.).
>
> I would personally do something like this:
>
> db.define_table('specialty',SQLField('name'))
>
> from gluon.tools import *
> auth=Auth(globals(),db)            # authentication/authorization
> # the fields below are requires you can add more
> auth.settings.table_user = db.define_table("auth_user",
>      db.Field("first_name", length=128,default=""),
>      db.Field("middle_name", length=128,default=""),
>      db.Field("last_name", length=128,default=""),
>      db.Field("email", length=128,default=""),
>      db.Field("web_page", length=128,default=""),
>      db.Field("is_patient", 'boolean', default=True),
>      db.Field("is_doctor", 'boolean', default=True),
>      db.Field("is_administrator", 'boolean', default=True),
>      db.Field("password", "password",readable=False,
> label="Password"),
>      db.Field("registration_key", length=128,
>               writable=False, readable=False, default=""))
> t = auth.settings.table_user
> t.first_name.requires = IS_NOT_EMPTY()
> t.last_name.requires = IS_NOT_EMPTY()
> t.password.requires = CRYPT() # password will be stored hashed
> t.email.requires = [IS_EMAIL(), IS_NOT_IN_DB(db, db.auth_user.email)]
> t.web_page.requires=IS_URL()
> auth.define_tables() ### auth_user will not be redefined!
>
> db.define_table('doctor_speciatly',
>   SQLField('doctor',db.auth_user),
>   SQLField('specialty',db.specialty))
>
> db.doctor_specialty.doctor.requires=IS_IN_DB(db
> (db.auth_user.is_doctor==True),
>              db.auth_user.id,'%(first_name)s %(last_name)s')
>
> db.doctor_specialty.specialty.requires=IS_IN_DB(db,
>              db.specialty.id,'%(name)s')
>
> db.define_table('prescription',
>   SQLField('doctor',db.auth_user),
>   SQLField('patient',db.auth_user),
>   SQLField('drug_name',length=128),
>   SQLField('prognosis','text'))
>
> db.prescription.doctor.requires=IS_IN_DB(db
> (db.auth_user.is_doctor==True),
>              db.auth_user.id,'%(first_name)s %(last_name)s')
>
> db.prescription.patient.requires=IS_IN_DB(db
> (db.auth_user.is_patient==True),
>              db.auth_user.id,'%(first_name)s %(last_name)s')
>
> Massimo
--~--~---------~--~----~------------~-------~--~----~
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