<commit_before><?php
/**
 * Visit controller.
 *
 * This file will render views from views/visits/
 *
 * PHP 5
 *
 * Copyright (c) <NAME> (<EMAIL>)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) <NAME> (<EMAIL>)
 * @link          http://github.com/bumetcs/cs673
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
 
App::uses('AppController', 'Controller');

/**
 * Static content controller
 *
 * Override this controller by placing a copy in controllers directory of an application
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
*/
class VisitsController extends AppController {
  
  public $uses = array();

  public $components = array('Algorithm');

  public function beforeFilter() {
    parent::beforeFilter();
    $this->authenticate_user();
    //$this->set('unitType', $_COOKIE['unitType']);
  }

/**
 * Displays a view
 *
 * @param mixed What page to display
 * @return void
 * @throws NotFoundException When the view file could not be found
 *  or MissingViewException in debug mode.
 */  
  public function index(){      
 
        $visits = $this->Visit->find('all'); 
        $this->set('visits', $visits);
  }
  
/**
 * Add a visit 
 *
 * @param weight, height, bps, bpd, A1c, eGFR, notes, a1c_goal, weight_goal, drug_allergies
 * @return void
 * @throws NotFoundException When the view file could not be found
 *  or MissingViewException in debug mode.
 */
  public function add(){  
    $p_id = $this->Session->read('patient_id');
    $this->Visit->Patient->id = $p_id;
    $patient = $this->Visit->Patient->read();
    $this->set('patient', $patient);    
    $this->request->data['Visit']['patient_id'] = $p_id;
    $this->request->data['DrugAllergy']['patient_id'] = $p_id;    
    $visit = $this->Visit->find('first', array(
      'conditions' => array('patient_id' => $p_id),
      'order' => 'Visit.modified DESC'));
    
    if ($this->request->is('post')) {
      $this->_add();
    } else {
      $this->request->data['DrugAllergy'] = $patient['DrugAllergy'];
      $this->request->data['MedhistoryComplaint'] = $visit['MedhistoryComplaint'];
      $p_height = $visit['VitalsLab']['height'];
      $this->set('p_height', $p_height);
      $this->request->data['MedhistoryComplaint']['complaints'] = null;   
    }
  }

 /**
 * The actual add action
 * @author <NAME>, <NAME>
 * @version 1.2, 2013-11-16
 */
  private function _add() {
    // Uset IDs to make sure these are insert comments.
    unset($this->request->data['Visit']['id']);
    unset($this->request->data['Treatment']['id']);
    unset($this->request->data['MedhistoryComplaint']['id']);
    
    $this->request->data['Treatment']['prescriber_username'] = "NO DATA";<commit_msg>Convert cm to ft for add visit default value<commit_after><?php
/**
 * Visit controller.
 *
 * This file will render views from views/visits/
 *
 * PHP 5
 *
 * Copyright (c) <NAME> (<EMAIL>)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) <NAME> (<EMAIL>)
 * @link          http://github.com/bumetcs/cs673
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
 
App::uses('AppController', 'Controller');

/**
 * Static content controller
 *
 * Override this controller by placing a copy in controllers directory of an application
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
*/
class VisitsController extends AppController {
  
  public $uses = array();

  public $components = array('Algorithm');

  public function beforeFilter() {
    parent::beforeFilter();
    $this->authenticate_user();
    //$this->set('unitType', $_COOKIE['unitType']);
  }

/**
 * Displays a view
 *
 * @param mixed What page to display
 * @return void
 * @throws NotFoundException When the view file could not be found
 *  or MissingViewException in debug mode.
 */  
  public function index(){      
 
        $visits = $this->Visit->find('all'); 
        $this->set('visits', $visits);
  }
  
/**
 * Add a visit 
 *
 * @param weight, height, bps, bpd, A1c, eGFR, notes, a1c_goal, weight_goal, drug_allergies
 * @return void
 * @throws NotFoundException When the view file could not be found
 *  or MissingViewException in debug mode.
 */
  public function add(){  
    $p_id = $this->Session->read('patient_id');
    $this->Visit->Patient->id = $p_id;
    $patient = $this->Visit->Patient->read();
    $this->set('patient', $patient);    
    $this->request->data['Visit']['patient_id'] = $p_id;
    $this->request->data['DrugAllergy']['patient_id'] = $p_id;    
    $visit = $this->Visit->find('first', array(
      'conditions' => array('patient_id' => $p_id),
      'order' => 'Visit.modified DESC'));
    
    if ($this->request->is('post')) {
      $this->_add();
    } else {
      $this->request->data['DrugAllergy'] = $patient['DrugAllergy'];
      $this->request->data['MedhistoryComplaint'] = $visit['MedhistoryComplaint'];
      $cm_height = $visit['VitalsLab']['height'];
      $inches = 0;
      $inches = $cm_height * 0.3937008;
      $feet = floor($inches / 12);
      $inches = ($inches % 12);
      $p_height = $feet . ("'") . $inches . ('"');
      $this->set('p_height', $p_height);
      $this->request->data['MedhistoryComplaint']['complaints'] = null;   
    }
  }

 /**
 * The actual add action
 * @author <NAME>, <NAME>
 * @version 1.2, 2013-11-16
 */
  private function _add() {
    // Uset IDs to make sure these are insert comments.
    unset($this->request->data['Visit']['id']);
    unset($this->request->data['Treatment']['id']);
    unset($this->request->data['MedhistoryComplaint']['id']);
    
    $this->request->data['Treatment']['prescriber_username'] = "NO DATA";
{'fraction_non_alphanumeric': 0.17162618626347112, 'fraction_numerical': 0.008846710632137687, 'mean_word_length': 3.351294611616515, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6796593', 'n_tokens_mistral': 2037, 'n_tokens_neox': 1922, 'n_words': 473}