<commit_before><?php
/**
 * OpenEyes.
 *
 * (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011
 * (C) OpenEyes Foundation, 2011-2013
 * This file is part of OpenEyes.
 * OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
 *
 * @link http://www.openeyes.org.uk
 *
 * @author OpenEyes <<EMAIL>>
 * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust
 * @copyright Copyright (c) 2011-2013, OpenEyes Foundation
 * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0
 */

/**
 * This is the model class for table "patient".
 *
 * The followings are the available columns in table 'patient':
 *
 * @property int $id
 * @property string $pas_key
 * @property string $title
 * @property string $first_name
 * @property string $last_name
 * @property string $dob
 * @property string $date_of_death
 * @property string $gender
 * @property string $hos_num
 * @property string $nhs_num
 * @property string $primary_phone
 * @property int $gp_id
 * @property int $practice_id
 * @property string $created_date
 * @property string $last_modified_date
 * @property int $created_user_id
 * @property int $last_modified_user_id
 * @property datetime $no_allergies_date
 * @property tinyint $deleted
 * @property int $ethnic_group_id
 *
 * The followings are the available model relations:
 * @property Episode[] $episodes
 * @property Address[] $addresses
 * @property Address $address Primary address
 * @property Contact[] $contactAssignments
 * @property Gp $gp
 * @property Practice $practice
 * @property Allergy[] $allergies
 * @property EthnicGroup $ethnic_group
 * @property CommissioningBody[] $commissioningbodies
 * @property SocialHistory $socialhistory
 *
 */
class Patient extends BaseActiveRecordVersioned
{
    const CHILD_AGE_LIMIT = 16;

    public $use_pas = true;
    private $_orderedepisodes;

    /**
     * Returns the static model of the specified AR class.
     *
     * @return Patient the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    public function behaviors()
    {
        return array(
            'ContactBehavior' => array(
                'class' => 'application.behaviors.ContactBehavior',
            ),
        );
    }

    /**
     * Suppress PAS integration.
     *
     * @return Patient
     */
    public function noPas()
    {
        // Clone to avoid singleton problems with use_pas flag
        $model = clone $this;
        $model->use_pas = false;

        return $model;
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'patient';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        return array(
            array('pas_key', 'length', 'max' => 10),
            array('hos_num', 'required', 'on' => 'pas'),
            array('hos_num, nhs_num', 'length', 'max' => 40),
            array('gender,is_local', 'length', 'max' => 1),
            array('dob, is_deceased, date_of_death, ethnic_group_id, gp_id, practice_id, is_local,nhs_num_status_id', 'safe'),
            array('deleted', 'safe'),<commit_msg>OE-6452 : add mandatory fields to the Add patient functionality<commit_after><?php
/**
 * OpenEyes.
 *
 * (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011
 * (C) OpenEyes Foundation, 2011-2013
 * This file is part of OpenEyes.
 * OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>.
 *
 * @link http://www.openeyes.org.uk
 *
 * @author OpenEyes <<EMAIL>>
 * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust
 * @copyright Copyright (c) 2011-2013, OpenEyes Foundation
 * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0
 */

/**
 * This is the model class for table "patient".
 *
 * The followings are the available columns in table 'patient':
 *
 * @property int $id
 * @property string $pas_key
 * @property string $title
 * @property string $first_name
 * @property string $last_name
 * @property string $dob
 * @property string $date_of_death
 * @property string $gender
 * @property string $hos_num
 * @property string $nhs_num
 * @property string $primary_phone
 * @property int $gp_id
 * @property int $practice_id
 * @property string $created_date
 * @property string $last_modified_date
 * @property int $created_user_id
 * @property int $last_modified_user_id
 * @property datetime $no_allergies_date
 * @property tinyint $deleted
 * @property int $ethnic_group_id
 *
 * The followings are the available model relations:
 * @property Episode[] $episodes
 * @property Address[] $addresses
 * @property Address $address Primary address
 * @property Contact[] $contactAssignments
 * @property Gp $gp
 * @property Practice $practice
 * @property Allergy[] $allergies
 * @property EthnicGroup $ethnic_group
 * @property CommissioningBody[] $commissioningbodies
 * @property SocialHistory $socialhistory
 *
 */
class Patient extends BaseActiveRecordVersioned
{
    const CHILD_AGE_LIMIT = 16;

    public $use_pas = true;
    private $_orderedepisodes;

    /**
     * Returns the static model of the specified AR class.
     *
     * @return Patient the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    public function behaviors()
    {
        return array(
            'ContactBehavior' => array(
                'class' => 'application.behaviors.ContactBehavior',
            ),
        );
    }

    /**
     * Suppress PAS integration.
     *
     * @return Patient
     */
    public function noPas()
    {
        // Clone to avoid singleton problems with use_pas flag
        $model = clone $this;
        $model->use_pas = false;

        return $model;
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'patient';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        return array(
            array('pas_key', 'length', 'max' => 10),
            array('hos_num', 'required', 'on' => 'pas'),
            array('hos_num, nhs_num', 'length', 'max' => 40),
            array('gender,is_local', 'length', 'max' => 1),
            array('dob, is_deceased, date_of_death, ethnic_group_id, gp_id, practice_id, is_local,nhs_num_status_id', 'safe'),
            array('gender, dob', 'required'),
            array('deleted', 'safe'),
{'fraction_non_alphanumeric': 0.10318684142893858, 'fraction_numerical': 0.011822153687997944, 'mean_word_length': 3.1620320855614974, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2734160', 'n_tokens_mistral': 2278, 'n_tokens_neox': 2154, 'n_words': 776}