<?php

namespace app\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use app\base\Converter;
use app\models\Applicationsettings;

/**
 * This is the model class for table "cms_baseline_preartbeliefs".
 *
 * The followings are the available columns in table 'cms_baseline_preartbeliefs':
 * @property integer $substance_use_id
 * @property string $substance_use_survey
 * @property string $substance_use_part_id
 * @property integer $substance_use_q1
 * @property integer $substance_use_q2
 * @property integer $substance_use_q3
 * @property integer $substance_use_q4
 * @property integer $substance_use_q5
 * @property integer $substance_use_q6
 * @property integer $substance_use_q7
 * @property integer $substance_use_q8
 * @property string $status
 * @property integer $create_time
 * @property integer $create_user
 * @property integer $update_time
 * @property integer $update_user
 */
 
class Substanceusefup extends \yii\db\ActiveRecord
{
	public $yes_no = [0 => "No", 1 => "Yes"];
	public $yes_no_dk = [0 => "No", 1 => "Yes", 997 => "Don't Know", 998 => "Refused"];
	public $q1 = [0 => "Never",1 => "1 time a month or less", 2 => "2−4 times a month", 3 => "2−3 times a week", 4 => "4 or more times a week"];
	public $q2 = [0 => "1 or 2",1 => "3 or 4", 2 => "5 or 6", 3 => "7 to 9", 4 => "10 or more"];
	public $q3 = [0 => "Never",1 => "Less than monthly", 2 => "Monthly", 3 => "Weekly", 4 => "Daily or almost daily"];
	Public $often = [1 => 'A few times', 2 => '1-3 times a month', 3 => 'About once a week', 4 => '2-5 times a week', 5 => 'About once a day', 6 => '2-3 times a day, almost every day', 7 => '4-9 times a day, almost every day', 8 => '10+ times a day, almost every day'];
	Public $visit;
	
	/**
	 * @inheritdoc
	 */
    public static function tableName()
	{
		return '{{%baseline_substanceuse}}';
	}

	/**
	 * @inheritdoc
	 */
	public function behaviors()
	{
		return [
			[
				'class' => TimestampBehavior::className(),
				'createdAtAttribute' => 'create_time',
				'updatedAtAttribute' => 'update_time',
				'value' => date('U'),
			]
		];
	}

	/**
	 * @inheritdoc
	 */
	public function rules()
	{
		return [			
			[['substance_use_survey','substance_use_loc', 'substance_use_part_id', 'substance_use_q1', 'substance_use_q4', 'substance_use_q16','visit_code'], 'required', 'message' => 'Cannot be blank.'],
			[['substance_use_q14','substance_use_q15','create_time', 'create_user', 'update_time', 'update_user'], 'integer', 'message' => 'Must be an integer'],	

            [['substance_use_q14','substance_use_q15'], 'number', 'min' => 0, 'tooSmall' => 'Negative value not allowed'],
			
			[['substance_use_q14','substance_use_q15'], 'string', 'max' => 3],
			[['substance_use_q2','substance_use_q3'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return $model->substance_use_q1 != '0';
			}, 'whenClient' => "function (attribute, value) {
				return $('#substanceusefup-substance_use_q1').val() != '0';
			}"],		
			
		[['substance_use_q6c','substance_use_q7c','substance_use_q8c','substance_use_q9c','substance_use_q10c','substance_use_q11c','substance_use_q12c','substance_use_q13c','substance_use_q14'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return $model->substance_use_q4 == '1';
			}, 'whenClient' => "function (attribute, value) {
				return $('#substanceusefup-substance_use_q4').val() == '1';
		}"],				
         
	 
	  [['substance_use_q6d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q6c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1'  && $('#substanceusefup-substance_use_q6c').val() == '1');
      }"],	
		   
		  	 
	  [['substance_use_q7d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q7c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1'  && $('#substanceusefup-substance_use_q7c').val() == '1');
      }"],		
	       
	 	 
	  [['substance_use_q8d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q8c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1'  && $('#substanceusefup-substance_use_q8c').val() == '1');
      }"],		  
	  
 	 
	  [['substance_use_q9d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q9c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1' && $('#substanceusefup-substance_use_q9c').val() == '1');
      }"],		   
		   	  
			 
	  [['substance_use_q10d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q10c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1'  && $('#substanceusefup-substance_use_q10c').val() == '1');
      }"],		

	 
	  [['substance_use_q11d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q11c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1'  && $('#substanceusefup-substance_use_q11c').val() == '1');
      }"],		   
		   
	      	 	 
	  [['substance_use_q12d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q12c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1' && $('#substanceusefup-substance_use_q12c').val() == '1');
      }"],		   
		   
	      	 	 
	  [['substance_use_q13d'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1'  &&  $model->substance_use_q13c == '1');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1'  && $('#substanceusefup-substance_use_q13c').val() == '1');
      }"],		   
		     
		[['substance_use_q15'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1' && $model->substance_use_q14 != '0');
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1' && $('#substanceusefup-substance_use_q14').val() != '0');
		}"],

     [['substance_use_q17a','substance_use_q18a','substance_use_q19a','substance_use_q20a','substance_use_q21a','substance_use_q22a','substance_use_q23a','substance_use_q24a','substance_use_q25a','substance_use_q26a','substance_use_q27a','substance_use_q28a'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return $model->substance_use_q16 == '1';
			}, 'whenClient' => "function (attribute, value) {
				return $('#substanceusefup-substance_use_q16').val() == '1';
	 }"],		
	 
	 [['substance_use_q17b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q17a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q17a').val() == '1' );
     }"],
		   
	  [['substance_use_q18b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q18a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q18a').val() == '1' );
     }"],	  
     [['substance_use_q19b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q19a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q19a').val() == '1' );
     }"],
	 
     [['substance_use_q20b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q20a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q20a').val() == '1' );
     }"],	 
	 
	 [['substance_use_q21b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q21a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q21a').val() == '1' );
     }"],
	 [['substance_use_q22b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q22a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q22a').val() == '1' );
     }"],
	  [['substance_use_q23b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q23a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q23a').val() == '1' );
     }"],
	  [['substance_use_q24b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q24a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q24a').val() == '1' );
     }"],
	 
	  [['substance_use_q25b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q25a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q25a').val() == '1' );
     }"],
	  [['substance_use_q26b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q26a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q26a').val() == '1' );
     }"],
	 [['substance_use_q27b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q27a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q27a').val() == '1' );
     }"],
	 [['substance_use_q28b'], 'required', 'message' => 'Cannot be blank.', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q28a == '1' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q28a').val() == '1' );
     }"],  	 	 
		
        [['substance_use_q13c'],'compare',  'compareAttribute'=>'substance_use_q4', 'operator'=>'>=', 'type'=>'number','skipOnEmpty'=>true, 'message' => 'All of Q5a-12a cannot be 0 (No). At least one of Q5a-12a must be 1 (Yes).', 'when' => function ($model) {
				return ($model->substance_use_q4 == '1' && $model->substance_use_q6c == '0' &&  $model->substance_use_q7c == '0' &&  $model->substance_use_q8c == '0' &&  $model->substance_use_q9c == '0' &&  $model->substance_use_q10c == '0' &&  $model->substance_use_q11c == '0' &&  $model->substance_use_q12c == '0' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q4').val() == '1' && $('#substanceusefup-substance_use_q6c').val() == '0' && $('#substanceusefup-substance_use_q7c').val() == '0' && $('#substanceusefup-substance_use_q8c').val() == '0' && $('#substanceusefup-substance_use_q9c').val() == '0' && $('#substanceusefup-substance_use_q10c').val() == '0' && $('#substanceusefup-substance_use_q11c').val() == '0' && $('#substanceusefup-substance_use_q12c').val() == '0');
		}"],	
			   		 
			
	  			
		[['substance_use_q28a'],'compare',  'compareAttribute'=>'substance_use_q16', 'operator'=>'>=', 'type'=>'number', 'skipOnEmpty'=>true, 'message' => 'All of Q16a-Q27a cannot be 0 (No). At least one of Q16a-Q27a must be 1 (Yes).', 'when' => function ($model) {
				return ($model->substance_use_q16 == '1' &&  $model->substance_use_q17a == '0' &&  $model->substance_use_q18a == '0' &&  $model->substance_use_q19a == '0' &&  $model->substance_use_q20a == '0' &&  $model->substance_use_q21a == '0' &&  $model->substance_use_q22a == '0' && $model->substance_use_q23a == '0' && $model->substance_use_q24a == '0' && $model->substance_use_q25a == '0' && $model->substance_use_q26a == '0' && $model->substance_use_q27a == '0' );
			}, 'whenClient' => "function (attribute, value) {
				return ($('#substanceusefup-substance_use_q16').val() == '1' && $('#substanceusefup-substance_use_q17a').val() == '0' && $('#substanceusefup-substance_use_q18a').val() == '0' && $('#substanceusefup-substance_use_q19a').val() == '0' && $('#substanceusefup-substance_use_q20a').val() == '0' && $('#substanceusefup-substance_use_q21a').val() == '0' && $('#substanceusefup-substance_use_q22a').val() == '0' && $('#substanceusefup-substance_use_q23a').val() == '0' && $('#substanceusefup-substance_use_q24a').val() == '0' && $('#substanceusefup-substance_use_q25a').val() == '0' && $('#substanceusefup-substance_use_q26a').val() == '0' && $('#substanceusefup-substance_use_q27a').val() == '0');
		}"],	
			['substance_use_q14', 'safe'],
			['substance_use_q14', 'q14validate'],
			[['substance_use_q15'], 'number', 'min' => 1, 'tooSmall' => 'Minimum value is {min}'],
			[['visit_code'], 'integer', 'message' => 'Must be an integer'],
			[['status'], 'string', 'max' => 1],
			[['record_date'], 'default', 'value' => strtotime(date('Y/m/d'))],
			
			];
	}

	public function q14validate() {
		
	    	if(($this->substance_use_q6c == 1  || $this->substance_use_q7c == 1 || $this->substance_use_q8c == 1  ||  $this->substance_use_q9c == 1 || $this->substance_use_q10c == 1 || $this->substance_use_q11c == 1 || $this->substance_use_q12c == 1 || $this->substance_use_q13c == 1 ) && $this->substance_use_q14 == 0) {
			$this->addError('substance_use_q14', 'This value should not be 0 if any value for Q5a-12a is coded as 1.');
		}
	}
	
	/**
	 * @inheritdoc
	 */
	public function attributeLabels()
	{
		return [
			'substance_use_id' => Yii::t('app', 'Substanceuse ID'),
			'substance_use_survey' => Yii::t('app', 'Survey'),
			'substance_use_loc' => Yii::t('app', 'Location'),
			'substance_use_part_id' => Yii::t('app', 'ICC Client ID'),
			
'visit_code' => Yii::t('app', 'Visit'),
'substance_use_q1' => Yii::t('app', '1. In the last six months, how often do you have a drink containing alcohol?'),
'substance_use_q2' => Yii::t('app', '2. In the last six months, how many standard drinks containing alcohol do you have on a typical day when drinking?'),
'substance_use_q3' => Yii::t('app', '3. In the last six months, how often do you have six or more drinks on one occasion?'),
'substance_use_q4' => Yii::t('app', '4. In the last six months, have you ever injected drugs for non-medicinal purposes?'),
'substance_use_q6c' => Yii::t('app', '5a. Have you injected heroin (e.g.,brown sugar,opium,smack) in the last 6 months?'),
'substance_use_q6d' => Yii::t('app', 'b. How often did you inject heroin in the last 6 months?'),
'substance_use_q7c' => Yii::t('app', '6a. Have you injected cocaine or crack in the last 6 months?'),
'substance_use_q7d' => Yii::t('app', 'b. How often did you inject cocaine or crack in the last 6 months?'),
'substance_use_q8c' => Yii::t('app', '7a. Have you injected stimulants (e.g.amphetamine,methamphetamine,YABA) in the last 6 months?'),
'substance_use_q8d' => Yii::t('app', 'b. How often did you inject stimulants in the last 6 months?'),
'substance_use_q9c' => Yii::t('app', '8a. Have you injected buprenorphine (e.g.norphine,ADDNOK,Tidi,Sublingual,Tidigesic) in the last 6 months?'),
'substance_use_q9d' => Yii::t('app', 'b. How often did you inject buprenorphine in the last 6 months?'),
'substance_use_q10c' => Yii::t('app', '9a. Have you injected allergy medicine / antihistamines (e.g.avil,phenargan) in the last 6 months?'),
'substance_use_q10d' => Yii::t('app', 'b. How often did you inject allergy medicine / antihistamines in the last 6 months?'),
'substance_use_q11c' => Yii::t('app', '10a. Have you injected painkillers (e.g. proxyvon, spasmoproxyvon, SP, Demerol,Fortwin,Morphine,Paxmax,Pentazocine,Pethidine, Tramadol) in the last 6 months?'),
'substance_use_q11d' => Yii::t('app', 'b. How often did you inject painkillers in the last 6 months?'),
'substance_use_q12c' => Yii::t('app', '11a. Have you injected sedatives, tranquilizers, anti- anxiety Drugs (e.g.Diazepam,Nitrosin,Alprazolam,Benzodiazepene,Calmpose,Clonazepam,Nitrazepam, Nitrovit,Paxam, Restyl) in the last 6 months?'),
'substance_use_q12d' => Yii::t('app', 'b. How often did you inject sedatives, tranquilizers, anti- anxiety Drugs in the last 6 months?'),
'substance_use_q13c' => Yii::t('app', '12a. Have you injected [other] in the last 6 months?'),
'substance_use_q13d' => Yii::t('app', 'b. How often did you inject [other] in the last 6 months?'),

'substance_use_q14' => Yii::t('app', '13. In the last 6 months, on how many days total did you inject ANY drug?'),
'substance_use_q15' => Yii::t('app', '14. In the last 6 months, on days you injected, on average how many times a day did you inject?'),
'substance_use_q16' => Yii::t('app', '15. Have you used any drugs for non-medicinal purposes by a non-injection route in the last 6 months? By non-injection route, I mean drugs that you sniffed, snorted, smoked or ingested.'),

'substance_use_q17a' => Yii::t('app', '16a. Have you used marijuana (e.g. smoke ganga, use hash, THC) in the last 6 months?'),
'substance_use_q17b' => Yii::t('app', 'b. How often did you use marijuana in the last 6 months?'),
'substance_use_q18a' => Yii::t('app', '17a. Have you used heroin (e.g., Smoke/chase opium or brown sugar, smack) in the last 6 months?'),
'substance_use_q18b' => Yii::t('app', 'b. How often did you use heroin in the last 6 months?'),
'substance_use_q19a' => Yii::t('app', '18a. Have you used stimulants (e.g. smoked or taken tablets methamphetamines,amphetamines, Yaba) in the last 6 months?'),
'substance_use_q19b' => Yii::t('app', 'b. How often did you use stimulants in the last 6 months?'),
'substance_use_q20a' => Yii::t('app', '19a. Have you used cocaine/crack in the last 6 months?'),
'substance_use_q20b' => Yii::t('app', 'b. How often did you use cocaine/crack in the last 6 months?'),
'substance_use_q21a' => Yii::t('app', '20a. Have you used hallucinogens (e.g. LSD, MDMA, ecstasy, X) in the last 6 months?'),
'substance_use_q21b' => Yii::t('app', 'b. How often did you use hallucinogens in the last 6 months?'),
'substance_use_q22a' => Yii::t('app', '21a. Have you used inhalants / solvents (e.g., petrol, glue, paint thinner) in the last 6 months?'),
'substance_use_q22b' => Yii::t('app', 'b. How often did you use inhalants / solvents in the last 6 months?'),
'substance_use_q23a' => Yii::t('app', '22a. Have you used buprenorphine (e.g. Norphine,ADDNOK, Sublingual, Tidi, Tidigesic) in the last 6 months?'),
'substance_use_q23b' => Yii::t('app', 'b. How often did you use buprenorphine in the last 6 months?'),
'substance_use_q24a' => Yii::t('app', '23a. Have you used allergy medicine / antihistamines (e.g. Avil, phernergan) in the last 6 months?'),
'substance_use_q24b' => Yii::t('app', 'b. How often did you use allergy medicine / antihistamines in the last 6 months?'),
'substance_use_q25a' => Yii::t('app', '24a. Have you used painkillers (e.g. Proxyvon,Spasmoproxyvon, SP, Demerol,Fortwin, Morphine, Paxmax,Pentazocine, Pethidine, Tramadol) in the last 6 months?'),
'substance_use_q25b' => Yii::t('app', 'b. How often did you use painkillers in the last 6 months?'),
'substance_use_q26a' => Yii::t('app', '25a. Have you used sedatives, tranquilizers, anti-Anxiety Drugs (e.g. Diazepam, Nitrosin,Alprazolam, Benzodiazepine,Calmpose, Clonazepam, Nitrazepam,Nitrovit, Paxam, Restyl) in the last 6 months?'),
'substance_use_q26b' => Yii::t('app', 'b. How often did you use sedatives, tranquilizers, anti-Anxiety Drugs in the last 6 months?'),
'substance_use_q27a' => Yii::t('app', '26a. Have you used chew intoxicating tobacco (e.g. mawa, zarda) in the last 6 months?'),
'substance_use_q27b' => Yii::t('app', 'b. How often did you use chew intoxicating tobacco in the last 6 months?'),
'substance_use_q28a' => Yii::t('app', '27a. Have you used any other drugs in the last 6 months?'),
'substance_use_q28b' => Yii::t('app', 'b. How often did you use [other] in the last 6 months?'),
			
			'status' => Yii::t('app', 'Status'),
			'create_time' => Yii::t('app', 'Create Time'),
			'create_user' => Yii::t('app', 'Create User'),
			'update_time' => Yii::t('app', 'Update Time'),
			'update_user' => Yii::t('app', 'Update User'),
			'record_date' => Yii::t('app', 'Record Date'),
			
		];
	}

	public function getVisits($id)
	{
		$Gmodel = \app\models\Visitmaster::find()->where(['NOT', ['visit_interval' => null]])->andWhere(["status" => 1])->andWhere(["visit_code" => $id])->one();
		if($Gmodel !== null) {			
				return $Gmodel->visit_name;
		} else
			return "-";
	}	
	
	public function getAppidusite()
	{
	   $Amodel = Applicationsettings::find()->orderBy("create_time DESC")->one();
        if ($Amodel !== null) {		
          return $Amodel->app_idu;
		 	
        } 
	}
	
}