Set up of patient registration system, some help needed.

Status
Not open for further replies.

kootjoo

Member
Hi,

I have to setup a patient registration system for a group of psychologists. Simply said I have the following setup.
1 table with 6 psychologists
1 table that contains the applications from patients

The psychologits want tha one of the is responsible for receiving the applications and assig patients to collegues. The basic setup for this works great. The psychologists can assign a collegue to a patient, if they do this an automatic e-mail is sent to the assigned psych, so far so good.

But I want it to work like this:
1 of the psychologists is assigned as a sort of admin. He receives the initial notification of a new patient, the others do not. How do I:
1. create the admin function in the psych table, so only one is admin. Only 1 admin must be possible!
So I get
Psych Admin
Psych 1 X
Psych 2 -
Psych 3 -

Now I must be able to change admin from Psych 1 to Psych 2.

2. how do I make sure that the admin is the one that gets the notification. So let the email plugin make a selection in the table where admin value = 1.

Hope you understand what I want and that it is possible.

Thanks,
KooTjoo
 
I have installed the yesy/no plugin. But what I would like to achieve that only on of the psychologits can be set to Yes.
 
1. create the admin function in the psych table, so only one is admin.
Use Joomla's groups and access levels to create the psychologist admin group. Then you can apply that access level to most parts of Fabrik. As you are assigning the user to that group - you have the control to only assign one.

Now I must be able to change admin from Psych 1 to Psych 2.
what criteria do you need to match for the other user to become an admin? Would it not be simpler to again use Joomla's user groups/access levels and assign that user a different role?

Same thing would be applicable for the yes/no plugin - create you access levels in Joomla then assign which access level can edit/add/view etc the yes/no element
 
Hi Rob,

Thanks for the answer. The access level is not the important thing here, I think. Maybe I can apply this also but teh email that is sent is the important thing.

The psychologist that is set to yes is the psychologist on duty and must get the initial email that a new patient has registered. He then can look at what kind of patient it is and assign the patient to another psychologist in the group. After he has assigned the other psychologist to a patient an email is sent to the psychologist that a patient is assigned to him (I have this working already).

So in short what I want.
1. The yes/no can only be assigned to 1 psychologist.
2. The initial email must be sent to the psychologist that is set to yes.

Thanks KooTjoo
 
So the person assigned as admin is on a revolving basis, in which case the acl system isn't appropriate.

Only 1 admin must be possible!
You would need to use the php form plugn (onAfterStore event), to get which psychologist was set as the admin when the form was submitted, and unset the others via an sql query. Something like:


PHP:
$db = JFactory::getDbo();
$isAdmin = $formModel->formData['is_admin_raw'];
 
if ($isAdmin == 1) {
  $userid = $formModel->formData[user_id_raw'];
  $query = $db->getQuery(true);
  $query->update('psychologists')->set('is_admin = 0')->where('user_id <> ' . $userid);
  $db->setQuery($query);
  $db->execute();
}

where 'user_id ' contains the user id and is_admin is a yes/no element
 
Hi,

Thanks. I have tried but get an php form plugin failed

In the PHP you mention the user_id. my table didn't contain a user_id. I have installed the user plugin with the psychologist registration form because they also have to be Joomla users. Do I have to add a user_id and group to the elements?

Is there a way to get more info about the PHP failed error?

Thanks,
KooTjoo
 
try this sorry
PHP:
$db = JFactory::getDbo();
$isAdmin = $formModel->formData['is_admin_raw'];
 
if ($isAdmin == 1) {
  $userid = $formModel->formData['user_id_raw'];
  $query = $db->getQuery(true);
  $query->update('psychologists')->set('is_admin = 0')->where('user_id <> ' . $userid);
  $db->setQuery($query);
  $db->execute();
}
 
as the admin element is a radio button the its data is posted as an array , I've updated the code for you on your site with :

PHP:
$db = JFactory::getDbo();
$isAdmin = $formModel->formData['is_admin_raw'];
$isAdmin = JArrayHelper::getValue($isAdmin, 0);
 
if ($isAdmin == 1) {
  $userid = $formModel->formData['user_id_raw'];
  $query = $db->getQuery(true);
  $query->update('elp_psychologen')->set('is_admin = 0')->where('user_id <> ' . $userid);
  $db->setQuery($query);
  $db->execute();
}
return true;
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top