Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

1155 Posts in 324 Topics by 274 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Need help with data model design

Page: 1
Go to End
Author Topic: Need help with data model design 403 Views
  • Piklets
    avatar
    Community Member
    34 posts

    Need help with data model design Link to this post

    I can't seem to come up with a way to get this data model structure working:

    Two types of users: patient and practice (at the moment they are defined as groups under Security in CMS)
    Patient has one practice (has_one), practice has many patients(has_many?)

    Patient has four fields: gender, program, progress, data
    Practice needs to be able to access its patients and edit their data

    How can I link a practice dataobject to a member in the practice security group
    and link a patient dataobject to a member in the patients security group?

    At the moment I edited sapphire/security/Member.php to add in extra fields for the patient, but thats not a good way at all, and it won't work when I try and implement the practice type of member!!

    Hope thats easy enough to understand!
    Thanks in advance~

  • Piklets
    avatar
    Community Member
    34 posts

    Re: Need help with data model design Link to this post

    I basically want two types of users, so I've looked up at http://doc.silverstripe.org/doku.php?id=member where there are some examples for extending Member.

    If I create some code like this:

    class Patient extends Member {
       static $db = array(
          "Gender" => "Enum('M,F')",
          "Program" => "Enum('C,E')",
          "Progress" => "Text",
          "Data" => "Text"
       );
       static $has_one = array(
          "Practice" => "Practice",
       );
    }


    and something like this:

    class Practice extends Member {
       static $db = array(
          // fields here
       );
       static $has_many = array(
          "Patients" => "Patient",
       );
    }

    First of all, will the above code work?

    Second of all, I have a registration module, with the main code being:

          // Create a new member and save the form into it
          $member = new Member();
          
          $form->saveInto($member);

          // Write to the databsae
          $member->write();

          // To do: add a status message on the form, using the standard form message system
          
          if($group = DataObject::get_one('Group', "ID = " . $this->defaultGroupID)) {
           $member->Groups()->add($group);
          }

    Can I change 'new Member()' to 'new Practice()' or 'new Patient()'?

    Then how would I create a foreach output of all a practice's patients?

    403 Views
Page: 1
Go to Top

Currently Online: There is nobody online.

Welcome to our latest member: fearofbuttons

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.