<?php

$identificationPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_IDENTIFICATION', $sessionKey, true);
$historyOfPresentProblemPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_HISTORY_OF_PRESENT_PROBLEM', $sessionKey, true);
$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_PSYCHIATRIC_HISTORY_PRIOR_EPISODES_OF_SYMPTOMS_DIAGNOSES_COURSES_OF_TREATMENT_ETC', $sessionKey, true);
$traumaHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_TRAUMA_HISTORY', $sessionKey, true);
$familyPsychiatricHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_FAMILY_PSYCHIATRIC_HISTORY', $sessionKey, true);
$medicalConditionsAndHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_MEDICAL_CONDITIONS_AND_HISTORY', $sessionKey, true);
$substanceUsePoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SUBSTANCE_USE', $sessionKey, true);
$familyHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_FAMILY_HISTORY', $sessionKey, true);
$socialHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SOCIAL_HISTORY', $sessionKey, true);
$spiritualCulturalFactorsPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SPIRITUAL_CULTURAL_FACTORS', $sessionKey, true);
$developmentalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_DEVELOPMENTAL_HISTORY', $sessionKey, true);
$educationalVocationalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_EDUCATIONAL_VOCATIONAL_HISTORY', $sessionKey, true);
$legalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_LEGAL_HISTORY', $sessionKey, true);
$snapPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SNAP', $sessionKey, true);
$otherImportantInformationPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_OTHER_IMPORTANT_INFORMATION', $sessionKey, true);


$identificationContent = [
	'value' => null,
];
if($identificationPoint->lastChildReview && $identificationPoint->lastChildReview->data) {
    $identificationPoint->lastChildReview->data = json_decode($identificationPoint->lastChildReview->data, true);
    $identificationContent = $identificationPoint->lastChildReview->data;
}

$historyOfPresentProblemContent = [
	'value' => null, 
];
if($historyOfPresentProblemPoint->lastChildReview && $historyOfPresentProblemPoint->lastChildReview->data){
	$historyOfPresentProblemPoint->lastChildReview->data = json_decode($historyOfPresentProblemPoint->lastChildReview->data, true);
	$historyOfPresentProblemContent = $historyOfPresentProblemPoint->lastChildReview->data;
}

$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent = [
	'value' => null, 
];
if($psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview && $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data){
	$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data = json_decode($psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data, true);
	$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent = $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data;
}

$traumaHistoryContent = [
	'value' => null, 
];
if($traumaHistoryPoint->lastChildReview && $traumaHistoryPoint->lastChildReview->data){
	$traumaHistoryPoint->lastChildReview->data = json_decode($traumaHistoryPoint->lastChildReview->data, true);
	$traumaHistoryContent = $traumaHistoryPoint->lastChildReview->data;
}

$familyPsychiatricHistoryContent = [
	'value' => null, 
];
if($familyPsychiatricHistoryPoint->lastChildReview && $familyPsychiatricHistoryPoint->lastChildReview->data){
	$familyPsychiatricHistoryPoint->lastChildReview->data = json_decode($familyPsychiatricHistoryPoint->lastChildReview->data, true);
	$familyPsychiatricHistoryContent = $familyPsychiatricHistoryPoint->lastChildReview->data;
}

$medicalConditionsAndHistoryContent = [
	'value' => null, 
];
if($medicalConditionsAndHistoryPoint->lastChildReview && $medicalConditionsAndHistoryPoint->lastChildReview->data){
	$medicalConditionsAndHistoryPoint->lastChildReview->data = json_decode($medicalConditionsAndHistoryPoint->lastChildReview->data, true);
	$medicalConditionsAndHistoryContent = $medicalConditionsAndHistoryPoint->lastChildReview->data;
}

$substanceUseContent = [
	'value' => null, 
];
if($substanceUsePoint->lastChildReview && $substanceUsePoint->lastChildReview->data){
	$substanceUsePoint->lastChildReview->data = json_decode($substanceUsePoint->lastChildReview->data, true);
	$substanceUseContent = $substanceUsePoint->lastChildReview->data;
}

$familyHistoryContent = [
	'value' => null, 
];
if($familyHistoryPoint->lastChildReview && $familyHistoryPoint->lastChildReview->data){
	$familyHistoryPoint->lastChildReview->data = json_decode($familyHistoryPoint->lastChildReview->data, true);
	$familyHistoryContent = $familyHistoryPoint->lastChildReview->data;
}

$socialHistoryContent = [
	'value' => null, 
];
if($socialHistoryPoint->lastChildReview && $socialHistoryPoint->lastChildReview->data){
	$socialHistoryPoint->lastChildReview->data = json_decode($socialHistoryPoint->lastChildReview->data, true);
	$socialHistoryContent = $socialHistoryPoint->lastChildReview->data;
}

$spiritualCulturalFactorsContent = [
	'value' => null, 
];
if($spiritualCulturalFactorsPoint->lastChildReview && $spiritualCulturalFactorsPoint->lastChildReview->data){
	$spiritualCulturalFactorsPoint->lastChildReview->data = json_decode($spiritualCulturalFactorsPoint->lastChildReview->data, true);
	$spiritualCulturalFactorsContent = $spiritualCulturalFactorsPoint->lastChildReview->data;
}

$developmentalHistoryContent = [
	'value' => null, 
];
if($developmentalHistoryPoint->lastChildReview && $developmentalHistoryPoint->lastChildReview->data){
	$developmentalHistoryPoint->lastChildReview->data = json_decode($developmentalHistoryPoint->lastChildReview->data, true);
	$developmentalHistoryContent = $developmentalHistoryPoint->lastChildReview->data;
}

$educationalVocationalHistoryContent = [
	'value' => null, 
];
if($educationalVocationalHistoryPoint->lastChildReview && $educationalVocationalHistoryPoint->lastChildReview->data){
	$educationalVocationalHistoryPoint->lastChildReview->data = json_decode($educationalVocationalHistoryPoint->lastChildReview->data, true);
	$educationalVocationalHistoryContent = $educationalVocationalHistoryPoint->lastChildReview->data;
}

$legalHistoryContent = [
	'value' => null, 
];
if($legalHistoryPoint->lastChildReview && $legalHistoryPoint->lastChildReview->data){
	$legalHistoryPoint->lastChildReview->data = json_decode($legalHistoryPoint->lastChildReview->data, true);
	$legalHistoryContent = $legalHistoryPoint->lastChildReview->data;
}

$snapContent = [
	'value' => null, 
];
if($snapPoint->lastChildReview && $snapPoint->lastChildReview->data){
	$snapPoint->lastChildReview->data = json_decode($snapPoint->lastChildReview->data, true);
	$snapContent = $snapPoint->lastChildReview->data;
}

$otherImportantInformationContent = [
	'value' => null, 
];
if($otherImportantInformationPoint->lastChildReview && $otherImportantInformationPoint->lastChildReview->data){
	$otherImportantInformationPoint->lastChildReview->data = json_decode($otherImportantInformationPoint->lastChildReview->data, true);
	$otherImportantInformationContent = $otherImportantInformationPoint->lastChildReview->data;
}


$contents = [
	'identification' => $identificationContent,
	'history_of_present_problem' => $historyOfPresentProblemContent,
	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent,
	'trauma_history' => $traumaHistoryContent,
	'family_psychiatric_history' => $familyPsychiatricHistoryContent,
	'medical_conditions_and_history' => $medicalConditionsAndHistoryContent,
	'substance_use' => $substanceUseContent,
	'family_history' => $familyHistoryContent,
	'social_history' => $socialHistoryContent,
	'spiritual_cultural_factors' => $spiritualCulturalFactorsContent,
	'developmental_history' => $developmentalHistoryContent,
	'educational_vocational_history' => $educationalVocationalHistoryContent,
	'legal_history' => $legalHistoryContent,
	'snap' => $snapContent,
	'other_important_information' => $otherImportantInformationContent,
];

$points = [
	'identification' => $identificationPoint,
	'history_of_present_problem' => $historyOfPresentProblemPoint,
	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint,
	'trauma_history' => $traumaHistoryPoint,
	'family_psychiatric_history' => $familyPsychiatricHistoryPoint,
	'medical_conditions_and_history' => $medicalConditionsAndHistoryPoint,
	'substance_use' => $substanceUsePoint,
	'family_history' => $familyHistoryPoint,
	'social_history' => $socialHistoryPoint,
	'spiritual_cultural_factors' => $spiritualCulturalFactorsPoint,
	'developmental_history' => $developmentalHistoryPoint,
	'educational_vocational_history' => $educationalVocationalHistoryPoint,
	'legal_history' => $legalHistoryPoint,
	'snap' => $snapPoint,
	'other_important_information' => $otherImportantInformationPoint,
];

$placeholders = [
	'identification' => 'age (71 at time of intake), ethnicity, religion, marital status, referral status, etc.',
	'history_of_present_problem' => 'symptoms, onset, duration, frequency, etc.',
	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => 'prior episodes of symptoms, diagnoses, courses of treatment, etc.',
	'trauma_history' => 'nature of trauma, when occurred, persons involved, etc.',
	'family_psychiatric_history' => 'history of mental illness in family, diagnoses, etc.',
	'medical_conditions_and_history' => 'current and past medical conditions, treatments, allergies, etc.',
	'substance_use' => 'history of substances used, including alcohol, tobacco, and prescription drugs other than prescribed, present substance use, etc.',
	'family_history' => 'family of origin, relationship with parents, siblings, significant others, etc.',
	'social_history' => 'significant relationships, social support, nature/quality of relationships, current community resources, etc.',
	'spiritual_cultural_factors' => 'important spiritual practices and communities, cultural influences, etc.',
	'developmental_history' => 'developmental milestones, delays, etc.',
	'educational_vocational_history' => 'level of education, current/past employment, hobbies, leisure activities, etc.',
	'legal_history' => 'arrest/summons history, sentencing, DUI occurrences, incarceration, civil litigation, family court matters, etc.',
	'snap' => 'strengths, needs, abilities, preferences, etc.',
	'other_important_information' => 'other important information relevant to treatment',
];

$labels = [
	'identification' => 'Identification', 
	'history_of_present_problem' => 'History of Present Problem', 
	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => 'Psychiatric History', 
	'trauma_history' => 'Trauma History', 
	'family_psychiatric_history' => 'Family Psychiatric History', 
	'medical_conditions_and_history' => 'Medical Conditions & History', 
	'substance_use' => 'Substance Use', 
	'family_history' => 'Family History', 
	'social_history' => 'Social History', 
	'spiritual_cultural_factors' => 'Spiritual/Cultural Factors', 
	'developmental_history' => 'Developmental History', 
	'educational_vocational_history' => 'Educational/Vocational History', 
	'legal_history' => 'Legal History', 
	'snap' => 'SNAP', 
	'other_important_information' => 'Other Important Information', 
];
?>
<div class="events-none form-read-mode">
	<div class="row">
		<div class="col-12">
			<div class="table-responsive">
				<table class="table table-sm table-bordered table-striped">
					@foreach($contents as $field => $content)
						<tr>
							<td>{{$labels[$field]}}:</td>
							<td>{{$content['value']}}</td>
						</tr>
					@endforeach  
				</table>
			</div>
		</div>
	</div>	
</div>