'. t("iAbetics implements the core iAbetics application in Drupal") .'

'; break; } return $output; } /** * Valid permissions for this module * @return array An array of valid permissions for the iAbetics module */ function iAbetics_perm() { return array( 'administer iAbetics', 'access iAbetics patient content', 'access iAbetics guardian content', 'access iAbetics researcher content', 'access iAbetics doctor content', 'access iAbetics medical professional content', ); } function iAbetics_menu() { $items = array(); $items['admin/settings/iAbetics'] = array( 'title' => t('iAbetics module settings'), 'description' => t('Administrative settings for the iAbetics application'), 'page callback' => 'drupal_get_form', 'page arguments' => array('iAbetics_admin'), 'access arguments' => array('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); return $items; } function iAbetics_admin() { $form = array(); $form['iAbetics_maxdisp'] = array( '#type' => 'textfield', '#title' => t('Maximum number of links'), '#default_value' => variable_get('iAbetics_maxdisp', 3), '#size' => 2, '#maxlength' => 2, '#description' => t("The maximum number of links to display in the block."), '#required' => TRUE, ); return system_settings_form($form); } function iAbetics_admin_validate($form, &$form_state) { $maxdisp = $form_state['values']['iAbetics_maxdisp']; if (!is_numeric($maxdisp)) { form_set_error('iAbetics_maxdisp', t('You must enter an integer for the maximum number of links.')); } else if ($maxdisp <= 0) { form_set_error('iAbetics_maxdisp', t('Maximum number of links must be positive.')); } else if ($maxdisp > 6) { form_set_error('iAbetics_maxdisp', t('System maximum of only six links permitted.')); } } function _iAbetics_user_fields_validate(&$edit) { switch($edit['account_type']) { case '0': // Patient // validate that they selected the "consent" checkbox if(empty($edit['consent_form'])) { form_set_error('consent_form', t('You must agree to the consent declaration when registering a new patient account')); } break; case '1': // Doctor case '3': // Medical professional // If one or other, but not both, of these fields are empty, then it's an error drupal_set_message(print_r(array( $edit['patient_last_name'], empty($edit['patient_last_name']), $edit['patient_auth_code'], empty($edit['patient_auth_code']), true XOR false, empty($edit['patient_last_name']) XOR empty($edit['patient_auth_code']), ),true)); if (empty($edit['patient_last_name']) XOR empty($edit['patient_auth_code'])) { form_set_error('patient_auth_code', t('If you wish to get authorization for patient data access, please enter BOTH last name and auth code. Otherwise, please leave BOTH blank and you can enter them later.')); } break; } } function _iAbetics_add_user_fields() { drupal_set_message(t('Fields with a (*) are required.')); drupal_set_message(t('After submitting your information below, an email will be sent to you with instructions on how to activate your account')); /* Basic account info */ $form['account_info'] = array( '#type' => 'fieldset', '#weight' => 2, ); $form['account_info']['first_name'] = array( '#type' => 'textfield', '#title' => t('First name'), '#size' => 32, '#maxlength' => 32, '#required' => TRUE, ); $form['account_info']['middle_name'] = array( '#type' => 'textfield', '#title' => t('Middle name'), '#size' => 32, '#maxlength' => 32, '#required' => TRUE, ); $form['account_info']['last_name'] = array( '#type' => 'textfield', '#title' => t('Last name'), '#size' => 32, '#maxlength' => 32, '#required' => TRUE, ); // Type of account, etc. $form['account_settings'] = array( '#type' => 'fieldset', '#title' => t('Account settings'), '#collapsible' => FALSE, '#weight' => 4, ); $account_types = array('-1' => t('Please specify'), '0' => t('Patient'), '1' => t('Doctor'), '2' => t('Researcher'), '3' => t('Other professional')); $form['account_settings']['account_type'] = array( '#type' => 'select', '#title' => t('Account type'), '#default_value' => $edit['account_type'] ? $edit['account_type'] : '-1', '#options' => $account_types, '#description' => t("What type of account would you like to create? Select 'Patient' if you are a diabetic and want to track your glucose levels and behaviors; select 'Doctor' if you are the doctor of a diabetic patient; select 'Researcher' to get access to anonymized glucose and behavior data from diabetic patients; select 'Other professional' if you are otherwise involved in the treatment of diabetics (eg. dietician, etc)"), '#required' => TRUE, ); drupal_add_js(drupal_get_path('module', 'iAbetics') .'/iAbetics_user_signup.js'); /* Doctor and medical professional only settings */ $form['account_settings']['doctor_wrapper'] = array( '#type' => 'fieldset', '#title' => t('Patient data access'), '#description' => t('To access your patient(s) data, you will need to specify the patient\'s last name and access code. If you have more than one patient, you will be able to enter additional access codes for each after creating your account.'), '#prefix' => '
', '#suffix' => '
', ); $form['account_settings']['doctor_wrapper']['patient_last_name'] = array( '#type' => 'textfield', '#title' => t('Patient\'s last name'), '#description' => t('Please specify the last name of your patient to access their data'), '#required' => FALSE, '#size' => 32, '#maxlength' => 32, ); $form['account_settings']['doctor_wrapper']['patient_auth_code'] = array( '#type' => 'textfield', '#title' => t('Patient authorization code'), '#description' => t('Your patient should provide you with an authorization code to access their data. If you have this code, please enter it here. Patients may obtain an authorization code by logging into their own account and visiting their account profile page, where the code will be listed.').'---- '.strtoupper(substr(base64_encode(sha1('Craig Hughes',TRUE)),1,6)), '#required' => FALSE, '#size' => 6, '#maxlength' => 6, ); /* Patient-only settings */ $form['account_settings']['patient_wrapper'] = array( '#tree' => FALSE, '#prefix' => '
', '#suffix' => '
', ); $form['account_settings']['patient_wrapper']['consent_form'] = array( '#type' => 'checkbox', '#title' => t('Consent form').'*', '#description' => t('Select this box if you have read, and agree to the ').l(t('consent form'), 'content/consent-form', array('attributes'=>array('class' => 'popups'))), ); $form['account_settings']['patient_wrapper']['privacy'] = array( '#type' => 'checkbox', '#title' => t('Allow access to my anonymized data for diabetes researchers'), '#defalut_value' => 0, '#description' => t('If you give permission here, your data will be anonymized and added to our medical research database, and made available to researchers all over the world for their studies. To encourage this sharing of information, we will provide our customers with a discounted subscription rate if they do agree to share this data for the benefit of everyone.'), ); $form['account_settings']['patient_wrapper']['contact_me'] = array( '#type' => 'checkbox', '#title' => t('Contact me if there is an opportunity for me to help diabetes researchers'), '#defalut_value' => 0, '#description' => t('From time to time, diabetes researchers might wish to contact out customers in order to do further work than is possible just through the anonymized data we provide. If you would like to be able to help in this work, please indicate that we can contact you about these opportunities here.'), ); $form['research_info'] = array( '#prefix' => '
', '#suffix' => '
', '#type' => 'fieldset', '#title' => t('Research information'), '#description' => t('The information in this section can be useful to researchers into diabetes. It is not required to be submitted, but completing this section is strongly encouraged'), '#collapsible' => FALSE, '#weight' => 6, ); $form['research_info']['birthdate'] = array( '#type' => 'date_popup', '#title' => t('Your birthdate'), '#description' => t('Please provide your birthdate for research purposes'), '#date_format' => 'd-M-Y', '#date_year_range' => '-100:+0', ); $possible_races = array('-1' => t('Decline to state'), '0' => t('Caucasian'), '1' => t('Asian'), '2' => t('African'), '3' => t('Pacific Islander'), '4' => t('Other')); $form['research_info']['race'] = array( '#type' => 'select', '#title' => t('Race'), '#default_value' => $edit['race'] ? $edit['race'] : '-1', '#options' => $possible_races, '#description' => t('This can be helpful for some research purposes'), '#required' => FALSE, ); $possible_types = array('0' => 'Unspecified', '1' => 'Type 1', '2' => 'Type 2'); $form['research_info']['diabetes_type'] = array( '#type' => 'select', '#title' => t('Diabetes type'), '#default_value' => $edit['diabetes_type'] ? $edit['diabetes_type'] : 0, '#options' => $possible_types, '#description' => t('Which type of diabetes do you have?'), '#required' => FALSE, ); $form['research_info']['diagnosis_date'] = array( '#type' => 'date_popup', '#title' => t('Diagnosis date'), '#description' => t('Please enter the date of your diabetes diagnosis'), '#date_format' => 'd-M-Y', '#date_year_range' => '-100:+0', ); $form['research_info']['job'] = array( '#type' => 'textfield', '#title' => t('Occupation'), '#description' => t('Please specify your occupation'), '#size' => 64, '#maxlength' => 64, ); $form['research_info']['notes'] = array( '#type' => 'textarea', '#title' => t('Any other notes'), '#description' => t('Please mention anything else here which might be of interest to researchers; remember that this field will be shared if you agree though, so be careful about noting anything which might de-anonymize you, if that is of concern to you'), '#cols' => 50, '#rows' => 8, ); return $form; } /** * Hook the user registration form and alter it to capture the information we need for iAbetics */ function iAbetics_user($op, &$edit, &$account, $category = NULL) { /* drupal_set_message("hook_user called for $op, $category"); */ switch($op) { case 'validate': _iAbetics_user_fields_validate($edit); break; case 'form': if($category != 'account') break; case 'register': return _iAbetics_add_user_fields(); } }