<?php

$keyToInputMap = [

	'generalAppearance' => [
		'Appropriate',
		'Disheveled',
		'Emaciated',
		'Obese',
		'Poor Hygiene',
		'Not Assessed'
	],

	'dressInput' => [
		'Appropriate',
		'Eccentric',
		'Seductive',
		'Bizarre',
		'Not Assessed'
	],

	'motorActivity' => [
		'Unremarkable',
		'Agitation',
		'Retardation',
		'Posturing',
		'Repetitive actions',
		'Tics',
		'Tremor',
		'Unusual Gait',
		'Not Assessed'
	],

	'insight' => [
		'Excellent',
		'Good',
		'Fair',
		'Poor',
		'Nil',
		'Not Assessed'
	],

	'judgment' => [
		'Excellent',
		'Good',
		'Fair',
		'Poor',
		'Nil',
		'Not Assessed'
	],

	'affect' => [
		'Congruent',
		'Incongruent',
		'Appropriate',
		'Inappropriate',
		'Reactive',
		'Constricted',
		'Blunted',
		'Flat',
		'Not Assessed'
	],

	'mood' => [
		'Euthymic',
		'Dysphoric',
		'Depressed',
		'Euphoric',
		'Grandiose',
		'Anxious',
		'Labile',
		'Irritable',
		'Angry',
		'Not Assessed'
	],

	'orientation' => [
		'X3: Oriented to Person, Place, and Time',
		'X2: Oriented to Person, Place; Impaired to Time',
		'X2: Oriented to Person, Time; Impaired to Place',
		'X2: Oriented to Time, Place; Impaired to Person',
		'X1: Oriented to Person; Impaired to Place, Time',
		'X1: Oriented to Place; Impaired to Person, Time',
		'X1: Oriented to Time; Impaired to Person, Place',
		'X0: Impaired to Person, Place, and Time',
		'Not Assessed'
	],

	'memory' =>[
		'Intact',
		'Poor Remote',
		'Poor Recent',
		'Not Assessed'
	],

	'attentionConcentration' => [
		'Good',
		'Distractible',
		'Variable',
		'Not Assessed',
    ],

	'thoughtContent' => [
		'Appropriate',
		'Preoccupied',
		'Obsessions',
		'Delusions: Persecutory',
		'Delusions: Bizarre',
		'Delusions: Grandeur',
		'Delusions: Guilt',
		'Delusions: Somatic',
		'Delusions: Ideas of Reference',
		'Delusions: Thought Broadcasting',
		'Delusions: Thought Control',
		'Not Assessed'
	],

	'perception' => [
		'Unremarkable',
		'Auditory Hallucinations',
		'Visual Hallucinations',
		'Olfactory Hallucinations',
		'Tactile Hallucinations',
		'Gustatory Hallucinations',
		'Not Assessed'
	],

	'thoughtProcess' => [
		'Unremarkable',
		'Blocking',
		'Circumstantial',
		'Flight of Ideas',
		'Loose Associations',
		'Perseveration',
		'Tangential',
		'Not Assessed'
	],

	'interviewBehavior' => [
		'Appropriate',
		'Aggressive',
		'Angry',
		'Apathetic',
		'Argumentative',
		'Child-like',
		'Demanding',
		'Drastic',
		'Evasive',
		'Hostile',
		'Irritable',
		'Passive',
		'Manipulative',
		'Withdrawn',
		'Uncooperative',
		'Not Assessed'
	],

	'speech' =>[
		'Normal',
		'Hesitant',
		'Pressured',
		'Slurred',
		'Soft',
		'Stuttering',
		'Mute',
		'Verbose',
		'Not Assessed'
	],

	'functionalStatus' => [
		'Intact',
		'Mildly Impaired',
		'Moderately Impaired',
		'Severely Impaired',
		'Variably Impaired',
		'Not Assessed'
	]

];

$keyToLabelMap = [
	'orientation' => 'Orientation',
	'generalAppearance' => 'General Appearance',
	'dressInput' => 'Dress',
	'motorActivity' => 'Motor Activity',
	'interviewBehavior' => 'Interview Behavior',
	'speech' => 'Speech',
	'mood' => 'Mood',
	'affect' => 'Affect',
	'insight' => 'Insight',
	'judgment' => 'Judgment/Impulse Control',
	'memory' => 'Memory',
	'attentionConcentration' => 'Attention/Concentration',
	'thoughtProcess' => 'Thought Process',
	'thoughtContent' => 'Thought Content',
	'perception' => 'Perception',
	'functionalStatus' => 'Functional Status'
];

$displayColumns = [
	'left' => ['orientation', 'generalAppearance', 'dressInput', 'motorActivity', 'interviewBehavior', 'speech', 'mood', 'affect'],
	'right' => ['insight', 'judgement', 'memory', 'attentionConcentration', 'thoughtProcess', 'thoughtContent', 'perception', 'functionalStatus']
];

if(!@$sessionKey) {
    $sessionKey = request()->cookie('sessionKey');
}
$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PSYCH_INTAKE_CURRENT_MENTAL_STATUS', $sessionKey, true);
$contentData = [
    'orientation' => null,
	'generalAppearance' => null,
	'dressInput' => null,
	'motorActivity' => null,
	'interviewBehavior' => null,
	'speech' => null,
	'mood' => null,
	'affect' => null,
	'insight' => null,
	'judgment' => null,
	'memory' => null,
	'attentionConcentration' => null,
	'thoughtProcess' => null,
	'thoughtContent' => null,
	'perception' => null,
	'functionalStatus' => null,
];
if ($point->lastChildReview && $point->lastChildReview->data) {
    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
    $contentData = $point->lastChildReview->data;
}
?>
<div class="events-none form-read-mode">
    <div>
        <div class="row">
            
            <div class="col-md-6">
				<table class="table table-sm table-striped table-bordered">
					@foreach($keyToInputMap as  $field => $options)
						@if(in_array($field, $displayColumns['left']))
							<tr>
								<td><b>{{$keyToLabelMap[$field]}}</b></td>
								<td>{{ @$contentData[$field] ?? '-' }}</td>
							</tr>
						@endif
					@endforeach
				</table>
                
            </div>
                
            <div class="col-md-6">
				<table class="table table-sm table-striped table-bordered">
					@foreach($keyToInputMap as  $field => $options)
						@if(in_array($field, $displayColumns['right']))
							<tr>
								<td><b>{{$keyToLabelMap[$field]}}</b></td>
								<td>{{ @$contentData[$field] ?? '-' }}</td>
							</tr>
						@endif
					@endforeach
				</table>
            </div>
        </div>   
    </div>    
    
</div>
