Ejemplo n.º 1
0
 /**
  * Create a control that is both a listbox and a textbox.
  */
 public static function createCustomSelectPanel($section_name, $sListRootName, $aChoices, $disabled, $aStatesEntry, $myvalues, $bShowCustomText = FALSE, $default_value_override = NULL, $nMaxlen = 400)
 {
     $controlroot = array();
     if ($bShowCustomText) {
         $initStyleListbox = 'display:none;';
         $initStyleTextbox = '';
     } else {
         $initStyleListbox = '';
         $initStyleTextbox = 'display:none;';
     }
     $sListboxName = $sListRootName . 'id';
     $sTextboxName = $sListRootName . 'customtx';
     if ($disabled) {
         //Only supporting readonly of the value.
         $controlroot[$sTextboxName] = array('#type' => 'textfield', '#disabled' => TRUE, '#default_value' => $myvalues[$sTextboxName]);
     } else {
         //START PICKLIST PART
         if ($bShowCustomText) {
             //No default selection in the picklist.
             $defaultlistvalue = '';
             //Make it select blank option
         } else {
             $defaultlistvalue = $myvalues[$sTextboxName];
             //Using the value as the key in the list.
         }
         $element = FormHelper::createSelectList($sListboxName, $aChoices, $disabled, $aStatesEntry, $myvalues, $defaultlistvalue);
         $controlroot[$sListboxName] = $element;
         $controlroot[$sListboxName]['#attributes'] = array('onchange' => 'notDefaultValuesInSection("' . $section_name . '")', 'style' => $initStyleListbox);
         //Declare a button that switches to TEXTBOX mode.
         $controlroot[$sListboxName . '_customize'] = array('#markup' => "\n" . '<div class="listalter-button-container"><a name="' . $sListRootName . 'makecustombtn" style="' . $initStyleListbox . '"  href="javascript:setAsCustomTextByName(' . "'" . $sListRootName . "'" . ')" title="Customize the selected value">CUSTOMIZE</a></div>', '#disabled' => $disabled);
         //CUSTOM TXT PORTION START
         if ($default_value_override !== NULL) {
             $default_value = $default_value_override;
         } else {
             $default_value = isset($myvalues[$sTextboxName]) ? $myvalues[$sTextboxName] : '';
         }
         $controlroot[$sTextboxName] = array('#type' => 'textfield', '#attributes' => array('onchange' => 'notDefaultValuesInSection("' . $section_name . '")'), '#disabled' => $disabled, '#states' => $aStatesEntry, '#default_value' => $default_value, '#maxlength' => $nMaxlen);
         if ($aStatesEntry !== NULL) {
             $controlroot[$sTextboxName]['#states'] = $aStatesEntry;
             //20140819
         }
         $controlroot[$sTextboxName]['#attributes'] = array('onchange' => 'notDefaultValuesInSection("' . $section_name . '")', 'style' => $initStyleTextbox);
         //Declare button that switches to LIST mode.
         $controlroot[$sTextboxName . '_listpick'] = array('#markup' => "\n" . '<div class="listalter-button-container"><a name="' . $sListRootName . 'makelistpickbtn" style="' . $initStyleTextbox . '" class="listalter-button" href="javascript:setAsPickFromListByName(' . "'" . $sListRootName . "'" . ')" title="Pick from list instead of custom text">LIST</a></div>', '#disabled' => $disabled);
         //CUSTOM TEXT DONE
     }
     return $controlroot;
 }
Ejemplo n.º 2
0
 /**
  * Get all the form contents for rendering
  * formType = A, E, D, V
  * @return type renderable array
  */
 function getForm($formType, $form, &$form_state, $disabled, $myvalues, $containerID = NULL)
 {
     $aOptions = $this->getAllOptions();
     $aFormattedKeywordText = $this->formatKeywordText($myvalues);
     if ($containerID == NULL) {
         $topidtxt = '';
     } else {
         $topidtxt = ' ID="' . $containerID . '" ';
     }
     $form['data_entry_area1'] = array('#prefix' => "\n<!--  Start of {$containerID} protocol-dataentry div section -->" . "\n<div {$topidtxt} class='protocol-dataentry'>\n", '#suffix' => "\n</div>\n<!--  End of {$containerID} protocol-dataentry div section -->\n", '#disabled' => $disabled);
     $form[] = array('#markup' => '<div id="protocol-lib-options-data">' . '<div style="visibility:hidden" id="json-option-values-all-sections"></div></div>');
     $form['data_entry_area1']['toppart'] = array('#type' => 'fieldset', '#attributes' => array('class' => array('data-entry-area')), '#disabled' => $disabled);
     if (isset($myvalues['protocol_shortname'])) {
         $protocol_shortname = $myvalues['protocol_shortname'];
     } else {
         $protocol_shortname = NULL;
     }
     $showfieldname_version = 'version';
     $showfieldname_shortname = 'protocol_shortname';
     $disabled_shortname = $disabled;
     //Default behavior
     $disabled_version = $disabled;
     //Default behavior
     if ($disabled || $formType == 'E' || $formType == 'A') {
         //Hidden values for key fields
         if ($formType == 'E') {
             $form['hiddenthings']['protocol_shortname'] = array('#type' => 'hidden', '#value' => $protocol_shortname, '#disabled' => FALSE);
             $showfieldname_shortname = 'show_protocol_shortname';
             $disabled_shortname = TRUE;
             $newversionnumber = isset($myvalues['version']) ? $myvalues['version'] + 1 : 1;
             $form['hiddenthings']['version'] = array('#type' => 'hidden', '#value' => $newversionnumber, '#disabled' => FALSE);
             $showfieldname_version = 'show_version';
         } else {
             if ($formType == 'A') {
                 $newversionnumber = 1;
                 $form['hiddenthings']['version'] = array('#type' => 'hidden', '#value' => $newversionnumber, '#disabled' => FALSE);
                 $showfieldname_version = 'show_version';
                 $myvalues['version'] = $newversionnumber;
             }
         }
         $disabled_version = TRUE;
     }
     $form['data_entry_area1']['toppart'][$showfieldname_shortname] = array('#type' => 'textfield', '#title' => t('Short Name'), '#default_value' => $protocol_shortname, '#size' => 20, '#maxlength' => 20, '#required' => TRUE, '#description' => t('The unique short name for this protocol'), '#disabled' => $disabled_shortname);
     $form['data_entry_area1']['toppart']['name'] = array('#type' => 'textfield', '#title' => t('Long Name'), '#default_value' => $myvalues['name'], '#size' => 128, '#maxlength' => 128, '#required' => TRUE, '#description' => t('The unique long name for this protocol'), '#disabled' => $disabled);
     $form['data_entry_area1']['toppart'][$showfieldname_version] = array('#type' => 'textfield', '#title' => t('Version number'), '#value' => $myvalues['version'], '#size' => 5, '#maxlength' => 5, '#description' => t('The version number increases each time a protocol is changed.  It does not, however, change when the default values or keywords of the protocol are edited.'), '#disabled' => $disabled_version);
     $sName = 'service_nm';
     $oChoices = new \raptor\raptor_datalayer_Choices();
     $aChoices = $oChoices->getServicesData('');
     if (count($aChoices) > 0) {
         //We only prompt for a service name if the database has services defined.
         $aStatesEntry = array();
         $element = FormHelper::createSelectList($sName, $aChoices, $disabled, $aStatesEntry, $myvalues);
         $form['data_entry_area1']['toppart'][$sName] = $element;
         $form['data_entry_area1']['toppart'][$sName]['#title'] = t('Service');
         $form['data_entry_area1']['toppart'][$sName]['#description'] = t('The service associated with this protocol');
         $form['data_entry_area1']['toppart']['active_yn'] = array('#type' => 'checkbox', '#title' => t('Protocol active (Y/N)'), '#default_value' => $myvalues['active_yn'], '#description' => t('Protocol is not available if it is not active'), '#disabled' => $disabled);
     }
     $form['data_entry_area1']['toppart']['filename'] = array('#type' => 'file', '#title' => t('Scanned protocol document'), '#value' => $myvalues['filename'], '#required' => FALSE, '#description' => t('The scanned image of the protocol for visual reference'), '#disabled' => $disabled);
     $form['data_entry_area1']['toppart']['modality_abbr'] = array('#type' => 'radios', '#options' => $aOptions['modality'], '#default_value' => $myvalues['modality_abbr'], '#title' => t('Modality'), '#description' => t('The modality of this protocol'), '#disabled' => $disabled);
     $form['data_entry_area1']['toppart']['modality_abbr']['#ajax'] = array('callback' => 'raptor_fetch_protocollib_options');
     $form['data_entry_area1']['toppart']['lowerbound_weight'] = array('#type' => 'textfield', '#title' => t('Lowerbound Patient Weight (kg)'), '#size' => 3, '#maxlength' => 3, '#default_value' => $myvalues['lowerbound_weight'], '#description' => t('Lowest weight to which this protocol applies (ignored if value is 0)'), '#disabled' => $disabled);
     $form['data_entry_area1']['toppart']['upperbound_weight'] = array('#type' => 'textfield', '#title' => t('Upperbound Patient Weight (kg)'), '#size' => 3, '#maxlength' => 3, '#default_value' => $myvalues['upperbound_weight'], '#description' => t('Highest weight to which this protocol applies (ignored if value is 0)'), '#disabled' => $disabled);
     //drupal_set_message('intial yn>>>'.print_r($myvalues['yn_attribs'],TRUE));
     $form['data_entry_area1']['toppart']['yn_attribs'] = array('#type' => 'checkboxes', '#options' => $aOptions['categories'], '#title' => t('Categories'), '#description' => t('Checking these boxes indicates the categories for this protocol.  These values are used by the automatic protocol suggestion engine.'), '#default_value' => $myvalues['yn_attribs'], '#disabled' => $disabled);
     $form['data_entry_area1']['keywords'] = array('#type' => 'fieldset', '#title' => t('Keyword Matching'), '#description' => t('For automatic protocol suggestion where keywords are in the order text'), '#attributes' => array('class' => array('data-entry1-area')), '#disabled' => $disabled);
     $form['data_entry_area1']['keywords']['keywords1'] = array('#type' => 'textfield', '#title' => t('Most Significant'), '#default_value' => $aFormattedKeywordText['keywords1'], '#size' => 100, '#maxlength' => 128, '#description' => t('Comma delimited list of most significant keywords'), '#disabled' => $disabled);
     $form['data_entry_area1']['keywords']['keywords2'] = array('#type' => 'textfield', '#title' => t('Moderately Significant'), '#default_value' => $aFormattedKeywordText['keywords2'], '#size' => 100, '#maxlength' => 128, '#description' => t('Comma delimited list of moderately significant keywords'), '#disabled' => $disabled);
     $form['data_entry_area1']['keywords']['keywords3'] = array('#type' => 'textfield', '#title' => t('Least Significant'), '#default_value' => $aFormattedKeywordText['keywords3'], '#size' => 100, '#maxlength' => 128, '#description' => t('Comma delimited list of least significant keywords'), '#disabled' => $disabled);
     $form['data_entry_area1']['defaultvaluespart'] = array('#type' => 'fieldset', '#title' => t('Default Values'), '#attributes' => array('class' => array('data-entry-area')), '#disabled' => $disabled, '#description' => t('The default options available here depend on the categories identfied for this protocol.'));
     $form['data_entry_area1']['defaultvaluespart']['input'] = $this->getInputArea1($this->m_oPI, $form_state, $disabled, $myvalues);
     $form['data_entry_area1']['defaultvaluespart']['protocolnotes_tx'] = array('#title' => t('Protocol Notes'), '#maxlength' => 500, '#description' => t('Custom text to prepopulate the protocol notes input area.'), '#type' => 'textarea', '#disabled' => $disabled, '#default_value' => $myvalues['protocolnotes_tx']);
     $form['data_entry_area1']['defaultvaluespart']['examnotes_tx'] = array('#title' => t('Exam Notes'), '#maxlength' => 500, '#description' => t('Custom text to prepopulate the exam notes input area for technologist.'), '#type' => 'textarea', '#disabled' => $disabled, '#default_value' => $myvalues['examnotes_tx']);
     $form['data_entry_area1']['codemappings'] = array('#type' => 'fieldset', '#title' => t('Code Mappings'), '#attributes' => array('class' => array('data-entry-area')), '#disabled' => $disabled, '#description' => t('<p>The codes that this protocol maps into so that RAPTOR can more granularly apply matching order criteria.</p>'));
     $form['data_entry_area1']['codemappings']['cpt_codes'] = array('#title' => t('CPT Codes'), '#maxlength' => 400, '#rows' => 2, '#description' => t('Comma delimited list of CPT codes to which this protocol maps'), '#type' => 'textarea', '#disabled' => $disabled, '#default_value' => $myvalues['cpt_codes']);
     $form['data_entry_area1']['codemappings']['radlex_codes'] = array('#title' => t('RADLEX Codes'), '#maxlength' => 400, '#rows' => 2, '#description' => t('Comma delimited list of RADLEX codes to which this protocol maps'), '#type' => 'textarea', '#disabled' => $disabled, '#default_value' => $myvalues['radlex_codes']);
     $form['data_entry_area1']['codemappings']['icd_codes'] = array('#title' => t('ICD Codes'), '#maxlength' => 400, '#rows' => 2, '#description' => t('Comma delimited list of ICD codes that this which this protocol maps'), '#type' => 'textarea', '#disabled' => $disabled, '#default_value' => $myvalues['icd_codes']);
     return $form;
 }